I have registered two queued event handlers on an event :
// in app/Providers/EventServiceProvider.php
//...
'App\Events\UserWasCreated' => [
'App\Handlers\Events\RegisterInSalesForce',
'App\Handlers\Events\SendMailToAdmin',
],
I want to run SendMailToAdmin
only if RegisterInSalesForce
is OK. I tried to return false
in RegisterInSalesForce
on failure and true
on success but it does not work.
What should I do ? Did I miss something ?
You cannot do it exactly like that, but you can do a workaround for that:
in your RegisterInSalesForce
event, you can fire another event (such as RegisteredInSales
) and then listen to it.
class RegisterInSalesForce {
public function handle()
{
// do your stuff
if($stuff == true){
$response = Event::fire(new RegisteredInSales);
}
}
}
Use a separate Event handler and add the logic to a method or else have another event "RegisteredInSalesForce" so a listener to it will dispatch the command "SendMailToAdmin".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With