I have a situation that I am sending a notification to multiple users and in past i have used this code:
foreach ($users as $user) {
$user->notify(new StaffNotify($dirtyAttributes, $user));
}
and I would check inside that notification if a user has a player_id
public function via($notifiable)
{
if ($this->user->player_id) {
return [OneSignalChannel::class, 'mail'];
} else {
return ['mail'];
}
}
(for OneSignal) and if he has I would send a push notification also on their mobile phone.
But with this new code:
\Notification::send($users, new StaffNotify($dirtyAttributes));
It is much better because i have only 1 request on my server instead of 250. I don't know how to check if a user has player_id because this works differently.
Does anyone know how to check the user before sending the notification?