I studied the Laraval.s notifications. I can not realize how to send bulk notifications to the specific users. I know their ids.
Should I use private channel or broadcast?
in laravel there are two way to send notificatons
$user=User::find(1) ;
$users=User::all() ;
$user->notify(new InvoicePaid($invoice))
// or
Notification::send($users,new InvoicePaid($invoice))
so both ways send only one notification but we can send it to single or multiple users. if you need to send multiple notifications to multiple users you should use loops:
$notifications=[new InvoicePaid($invoice) ]
foreach($notifications as $notification)
{
Notification::send($users,$notification)
}
also there is a better way to handle this.you can use event and it is better to use event to send notification or perform other task after a specific action. for example define a event as userRegisterd. then you can assign one or more listener to this event like sendNewUserNotification , congratulationsNotification.
in each listener notify the users