Is a beforeFind on a Model a bad idea? |
(06-29-2020, 10:29 PM)tgix Wrote: What am I missing? It is possible to define custom events. The (static) class method Events::on() allows you to register an event using any name you like. File: /app/Config/Events.php PHP Code: Events::on('before_findAll', [$modelInstance, 'modelMethod']); // Call modelMethod on an existing Model instance At the appropriate logical spot in your code, something like this PHP Code: \CodeIgniter\Events\Events::trigger('before_findAll', $model, 'modelMethod'); You can pass other arguments in trigger if needed. Events Docs |
Messages In This Thread |
Is a beforeFind on a Model a bad idea? - by tgix - 06-29-2020, 10:29 PM
RE: Is a beforeFind on a Model a bad idea? - by marcogmonteiro - 06-30-2020, 03:08 AM
RE: Is a beforeFind on a Model a bad idea? - by tgix - 06-30-2020, 05:35 AM
RE: Is a beforeFind on a Model a bad idea? - by dave friend - 06-30-2020, 05:44 AM
RE: Is a beforeFind on a Model a bad idea? - by kilishan - 06-30-2020, 12:02 PM
RE: Is a beforeFind on a Model a bad idea? - by tgix - 06-30-2020, 12:23 PM
RE: Is a beforeFind on a Model a bad idea? - by Wells - 07-01-2020, 09:18 PM
RE: Is a beforeFind on a Model a bad idea? - by MGatner - 07-18-2020, 07:05 AM
|