Can't you simply rename the event to "login" with a handler of "loggedin" for example, and pass the user model into the "login" event which can then be accessed in the "loggedin" event handler as a property of the event "login"?
Just thinking out loud.
I guess I'm just not understanding how events are supposed to work - thanks for your suggestion but doesn't that put me back where I started - with a handler explicitly tied to one event?
What I want to achieve, and how it should all work in my mind is like this:
This way I have one handler that does a specific task being used by more than one event, hence keeping my handler DRY.
What am I missing!?
Did you ever find a solution to this ollie-new?
I have the same situation where I want to re-use a handler that creates an audit log...obviously it would be awesome and DRY to re-use this throughout the app under multiple events.
Cheers Dan
apparently you can assciate multiple things to one event in event service provider file?
protected $listen = [ 'mphm\Events\UserRegistered' => [ 'mphm\Listeners\EmailActivationLink', //first thing to happen '.....', //2nd thing etc ],
'mphm\Events\UserForgotPassword' => [
'mphm\Listeners\EmailPasswordForgottenLink',
]
];
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community