Laravel Notifications: Multi-Channel Messages

Send notifications via email, SMS, Slack, and more with Laravel's notification system.

1 min readLaravelاقرأ بالعربية

Multi-channel notifications:

Create Notification

class OrderShipped extends Notification
{
    public function via($notifiable)
    {
        return ['mail', 'database', 'slack'];
    }

    public function toMail($notifiable)
    {
        return (new MailMessage)
            ->line('Your order has shipped!');
    }
}

Send Notification

php
$user->notify(new OrderShipped($order));

Queue Notifications

class OrderShipped extends Notification implements ShouldQueue
{
    // Automatically queued
}
All articles

Keep reading