Notifications — Laravel 10 Discovery Training

Notifications allow you to create an alert that you can send on different channels (email, slack notification, sms…). As for the other elements it is possible to create a notification using artisan.

php artisan make:notification InvoicePaid

This will generate a class that will contain different methods to convert data for the chosen notification systems. The methods will depend on the chosen channel and I refer you to the documentation.

Then to send a notification we have access to a method notify().

$user->notify(new InvoicePaid($invoice));

But it is also possible to send a notification from the Notification panel.

use Illuminate\Support\Facades\Notification;

Notification::send($users, new InvoicePaid($invoice));

This also allows you to send notifications to multiple users.