Here is my code working to send notification email to multiple users
$users = User::whereIn('id', $userIds)->get();
\Notification::send($users, new DealPublished($deal));
It works but if I want to delay it like that
$users = User::whereIn('id', $userIds)->get();
$when = Carbon::now()->addSecond();
\Notification::send($users, new DealPublished($deal))->when($when);
Error is
FatalThrowableError in DealController.php line 226:
Call to a member function when() on null
How can I send notification email to multiple users using queue and Notification Facade ?
Thank's for help
Try it like this:
\Notification::send($users, (new DealPublished($deal))->delay($when));
I think you should try this:
$when = Carbon::now()->addSecond(10);
\Notification::send($users, new DealPublished($deal))->later($when);
OR
\Notification::send($users, new DealPublished($deal))->when($when);
Hope this work for you!
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