Laravel 5.3 notifications unified the channels

Sending the same event by email, SMS and a database record meant three call sites and three formats to keep in step. 5.3 makes the notification one class that knows how to render itself per channel.

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

    public function toMail($notifiable): MailMessage
    {
        return (new MailMessage)->line('Your order is on its way.');
    }

    public function toArray($notifiable): array
    {
        return ['order_id' => $this->order->id];
    }
}

via() receives the notifiable, so per-user channel preferences are a condition rather than a branch at the call site. Notifications queue as a unit, which is usually right — but a failure on one channel fails the job, so an SMS provider being down will retry the email as well unless the channels are split into separate notifications.