'Laravel notification (queue) - Custom Channels handle fail send
How can I fail to send notifications in laravel with Custom Channels?
$user->notify(new InvoicePaid($invoice));
Notification class
class InvoicePaid extends Notification implements ShouldQueue
{
use Queueable;
/**
* Get the notification channels.
*
* @param mixed $notifiable
* @return array|string
*/
public function via($notifiable)
{
return [VoiceChannel::class];
}
/**
* Get the voice representation of the notification.
*
* @param mixed $notifiable
* @return VoiceMessage
*/
public function toVoice($notifiable)
{
// ...
}
}
VoiceChannel Class
It's my custom channel. Is my problem I cannot handle the failure to send a notification to add to the failed job for sending again in the future?
class VoiceChannel
{
/**
* Send the given notification.
*
* @param mixed $notifiable
* @param \Illuminate\Notifications\Notification $notification
* @return void
*/
public function send($notifiable, Notification $notification)
{
$message = $notification->toVoice($notifiable);
// Send notification to the $notifiable instance...
// oh, sorry, voice API is down now. Please try after 10 min
// how to add this notification in the failed job to try again ??**
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
