I have configured it to send notifications to users who can be members or non-members.
Notifications are sent via email, database, and broadcast.
At this time, if the user is a member, he will receive a notification through e-mail, database, and broadcast, and if the user is a non-member, the user will receive a notification through e-mail.
If the user is a member, the code below is called.
User::find($userId)->notify($notificationInstance);
If the user is a non-member, the code below is called.
Notification::route('mail', $emailAddress)->notify($notificationInstance);
If the user is a member, it works as expected.
However, for non-members, it is transmitted through e-mail and broadcast. Why does broadcast work? Also, why are databases excluded?
...
public function via($notifiable)
{
if ($notifiable instanceof AnonymousNotifiable) {
if (Arr::exists($notifiable->routes, 'mail')) {
$via[] = 'mail';
}
if (...) {
$via[] = '...';
}
return $via;
}
}
...
Solved. Here my code.