Skip to content

Commit 7912da2

Browse files
committed
Write broadcast notification type customization bit and add an example
1 parent 3f7dd37 commit 7912da2

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

notifications.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,24 @@ The `broadcast` channel broadcasts notifications using Laravel's [event broadcas
563563
]);
564564
}
565565

566+
In addition to the data you specify, broadcast notifications will also contain a `type` field containing the class name of the notification.
567+
568+
#### Customizing The Notification Type
569+
570+
If you would like to customize notification type that is passed to your JavaScript client, you may define a `broadcastType` method in the notification class:
571+
572+
use Illuminate\Notifications\Messages\BroadcastMessage;
573+
574+
/**
575+
* Get the type of the notification being broadcast.
576+
*
577+
* @return string
578+
*/
579+
public function broadcastType($notifiable)
580+
{
581+
return 'broadcast.message';
582+
}
583+
566584
#### Broadcast Queue Configuration
567585

568586
All broadcast notifications are queued for broadcasting. If you would like to configure the queue connection or queue name that is used to queue the broadcast operation, you may use the `onConnection` and `onQueue` methods of the `BroadcastMessage`:
@@ -571,8 +589,6 @@ All broadcast notifications are queued for broadcasting. If you would like to co
571589
->onConnection('sqs')
572590
->onQueue('broadcasts');
573591

574-
> {tip} In addition to the data you specify, broadcast notifications will also contain a `type` field containing the class name of the notification.
575-
576592
<a name="listening-for-notifications"></a>
577593
### Listening For Notifications
578594

0 commit comments

Comments
 (0)