Jump to content

Alert hook no longer works


Recommended Posts

Hi,

 

We've had this hook configured for more than a year, and I just realised it has stopped working.

<?php

use WHMCS\User\Alert;
use Illuminate\Database\Capsule\Manager as Capsule;

add_hook('ClientAlert', 1, function($client) {

    $ccf = Capsule::table('tblcustomfieldsvalues')
                ->where('relid',$client->id)
                ->where('fieldid','90')
                ->pluck('value');

    if (empty($ccf)) {
        return new Alert('DISPLAY THIS MESSAGE IF FIELDID 90 IS EMPTY', 'info', 'https://link.com', 'BUTTON');
    }
});

I have no idea why it no longer works. Any help is much appreciated!

Edited by DennisMidjord
Link to comment
Share on other sites

1 hour ago, DennisMidjord said:

I have no idea why it no longer works. Any help is much appreciated!

Laravel changed the functionality of 'pluck' to something else in recent versions (last year I think), and replaced it with value... so all you should need to do is change that last line from ->pluck('value') to (ironically)...

->value('value');

 

Link to comment
Share on other sites

4 hours ago, DennisMidjord said:

Hi,

 

We've had this hook configured for more than a year, and I just realised it has stopped working.


<?php

use WHMCS\User\Alert;
use Illuminate\Database\Capsule\Manager as Capsule;

add_hook('ClientAlert', 1, function($client) {

    $ccf = Capsule::table('tblcustomfieldsvalues')
                ->where('relid',$client->id)
                ->where('fieldid','90')
                ->pluck('value');

    if (empty($ccf)) {
        return new Alert('DISPLAY THIS MESSAGE IF FIELDID 90 IS EMPTY', 'info', 'https://link.com', 'BUTTON');
    }
});

I have no idea why it no longer works. Any help is much appreciated!

Can I keep the current structure that will return an array and check element 0.

2 hours ago, brian! said:

Laravel changed the functionality of 'pluck' to something else in recent versions (last year I think), and replaced it with value... so all you should need to do is change that last line from ->pluck('value') to (ironically)...


->value('value');

 

if (empty($ccf[0])) {
Link to comment
Share on other sites

I shall refer you to our chief plucker (to coin a phrase!), twhiting9275, as he continues to use pluck in this way - this is how he does it...

$ccf = Capsule::table('tblcustomfieldsvalues')->where('relid',$client->id)->where('fieldid','90')->pluck('value');
if (is_array($ccf))
{
	$ccf = $ccfsecurityq['0'];
}
if (empty($ccf))

personally, i'd just change pluck to value, but you can do it your way if you prefer.

Link to comment
Share on other sites

2 minutes ago, brian! said:

I shall refer you to our chief plucker (to coin a phrase!), twhiting9275, as he continues to use pluck in this way - this is how he does it...


$ccf = Capsule::table('tblcustomfieldsvalues')->where('relid',$client->id)->where('fieldid','90')->pluck('value');
if (is_array($ccf))
{
	$ccf = $ccfsecurityq['0'];
}
if (empty($ccf))

personally, i'd just change pluck to value, but you can do it your way if you prefer.

No doubt your tip is 1000 times more practical.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated