DennisHermannsen Posted August 28, 2018 Share Posted August 28, 2018 (edited) 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 August 28, 2018 by DennisMidjord 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 28, 2018 Share Posted August 28, 2018 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'); 1 Quote Link to comment Share on other sites More sharing options...
DennisHermannsen Posted August 28, 2018 Author Share Posted August 28, 2018 Thanks once again, brian! It works perfectly now 🙂 0 Quote Link to comment Share on other sites More sharing options...
edvancombr Posted August 28, 2018 Share Posted August 28, 2018 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])) { 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 28, 2018 Share Posted August 28, 2018 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. 0 Quote Link to comment Share on other sites More sharing options...
edvancombr Posted August 28, 2018 Share Posted August 28, 2018 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. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 28, 2018 Share Posted August 28, 2018 his solution is better if you need the same hook to work in both v6 and v7.... but if you know you're going to be using v7, then it's easier to just use ->value. 0 Quote Link to comment Share on other sites More sharing options...
edvancombr Posted August 28, 2018 Share Posted August 28, 2018 9 minutes ago, brian! said: his solution is better if you need the same hook to work in both v6 and v7.... but if you know you're going to be using v7, then it's easier to just use ->value. Thanks for the clarification! 0 Quote Link to comment Share on other sites More sharing options...
DennisHermannsen Posted August 28, 2018 Author Share Posted August 28, 2018 Brian, do you know if it's possible to create a button (either an X or a button saying 'Close') on the notification that sets the value to 'On' in the database? 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.