Skip to content

Commit d2b1446

Browse files
committed
allow broadcast on demand notifications
1 parent a833a88 commit d2b1446

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Illuminate/Notifications/Events/BroadcastNotificationCreated.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
use Illuminate\Broadcasting\PrivateChannel;
66
use Illuminate\Bus\Queueable;
77
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
8+
use Illuminate\Notifications\AnonymousNotifiable;
89
use Illuminate\Queue\SerializesModels;
10+
use Illuminate\Support\Arr;
911

1012
class BroadcastNotificationCreated implements ShouldBroadcast
1113
{
@@ -54,7 +56,12 @@ public function __construct($notifiable, $notification, $data)
5456
*/
5557
public function broadcastOn()
5658
{
57-
$channels = $this->notification->broadcastOn();
59+
if ($this->notifiable instanceof AnonymousNotifiable &&
60+
$this->notifiable->routeNotificationFor('broadcast')) {
61+
$channels = Arr::wrap($this->notifiable->routeNotificationFor('broadcast'));
62+
} else {
63+
$channels = $this->notification->broadcastOn();
64+
}
5865

5966
if (! empty($channels)) {
6067
return $channels;

0 commit comments

Comments
 (0)