I decided to follow various "best practice" recommendations I've seen and put Event::listen code in the Model::boot static method for the relevant model. This works perfectly for half a dozen of them, completely fails to execute for others.
All extend from the same base class (which in turn extends \Illuminate\Database\Eloquent\Model)
All use the public static function boot() method
All use the same \Event::listen('event',function(){}); format
It's not a problem with multiple listeners, I can put two in the same working Model and they both trigger, but none will every be triggered in the non-working ones.
There's not even any code to paste in, I'm using by-the-book (to the best of my knowledge) code,
class MyClass extends \Illuminate\Database\Eloquent\Model { public static function boot() { \Event::listen('my.event', function($arg1, $arg2){ \Log::debug("This may or may not trigger."); }); } } No Exceptions are thrown, no errors logged, it just doesn't run. I can c&p the code into one of the "working" Models and it will work exactly as expected.
Is there some obscure problem or nuance I'm missing? This inconsistency is maddening.
user.joined.companyin the latter Model, since in this case it would be the Company doing things based on the User's action. The now-obvious problem is that the Company model might not have been used anywhere and so wouldn't be listening. I'll just have to move the events into the actor's class instead.