Answer the question
In order to leave comments, you need to log in
Why are notifications not being sent in Laravel 8?
Through the facade I send notifications with a delay
foreach ($orders as $i => $order)
{
Notification::send($order, (new OrdersDelivered($text_template))
->delay(now()->addSeconds($i * 30))
);
}
class OrdersDelivered extends Notification implements ShouldQueue
{
use Queueable;
private string $text;
public function __construct($text)
{
$this->text = $text;
}
public function via($notifiable): array
{
return [WhatsappChannel::class];
}
public function toWhatsapp($notifiable): WhatsappMessage
{
return (new WhatsappMessage())
->to($notifiable->client_phone)
->text($this->text)
->totalOrders($notifiable->total);
}
}
class WhatsappChannel
{
public function send(mixed $notifiable, Notification $notification)
{
$message = $notification->toWhatsapp($notifiable);
WhatsappApi::send($message);
}
}
implements ShouldQueue
. I need to use a queue, but when the handler pulls out tasks, the send method on the channel is not even called. At the same time, all tasks get into the queueAnswer the question
In order to leave comments, you need to log in
Most likely, you need to start the queue handler, the queue itself does nothing, you need to execute the command
php artisan queue:work
or
php artisan queue:listen
Note that the handler, according to the documentation, must be launched before sending notifications to the queue!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question