Notify Multiple Users in Laravel
Laravel supports a wide range of possibilities when we want to notify a user. Mostly, we want to notify only one user at the time, but also we have the back-end to notify multiple users at the same time.
With the help of the Notification facade, we can notify multiple users easily. Of course, you could just loop through a set of users, and call the $user->noitfy(…) method, but for sure it’s more elegant to avoid loops where it’s possible. So let’s see:
use Illuminate\Support\Facades\Notification; // Get the users $users = User::where(...)->get(); // Send the notifications Notification::send($users, new TaskAssigned($task));