Skip to content

Commit bdd8347

Browse files
getting notification recipients from the correct place - fixes #1
1 parent 0730480 commit bdd8347

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Managers/NotificationManager.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use BinaryBuilds\LaravelMailManager\Models\MailManagerMail;
66
use Illuminate\Contracts\Queue\ShouldQueue;
7+
use Illuminate\Notifications\AnonymousNotifiable;
78

89
/**
910
* Class NotificationManager
@@ -26,9 +27,18 @@ public static function handleMailSendingEvent( $event )
2627
]);
2728
}
2829
else {
30+
$recipients = [];
31+
if( $event->notifiable instanceof AnonymousNotifiable ) {
32+
if( is_array($event->notifiable->routes) ) {
33+
$recipients = array_values($event->notifiable->routes);
34+
}
35+
} else {
36+
$recipients = [ $event->notifiable->routeNotificationFor('mail') ];
37+
}
38+
2939
MailManagerMail::create([
3040
'uuid' => $event->notification->id,
31-
'recipients' => array_values($event->notifiable->routes),
41+
'recipients' => $recipients,
3242
'subject' =>$event->notification->toMail($event->notifiable)->subject,
3343
'mailable_name' => get_class($event->notification),
3444
'mailable' => serialize(clone $event->notification),

0 commit comments

Comments
 (0)