F
Filament5mo ago
Veur

Broadcasted Notifications are completed in Horizon, but not received by Reverb

I've installed and configured Laravel Reverb & Echo. It all works fine with traditional Laravel notification classes:
public function toBroadcast(object $notifiable): BroadcastMessage
{
$data = [
'order_id' => $this->order->id,
'amount' => 123,
];

return (new BroadcastMessage($data))->onConnection('sync');
}
public function toBroadcast(object $notifiable): BroadcastMessage
{
$data = [
'order_id' => $this->order->id,
'amount' => 123,
];

return (new BroadcastMessage($data))->onConnection('sync');
}
But when I try to send a Filament Notification, it doesn't work. The jobs are handled by the queue, but nothing happens in Reverb:
public function toBroadcast(object $notifiable): BroadcastMessage
{
return \Filament\Notifications\Notification::make()
->title('Saved successfully')
->getBroadcastMessage();
}
public function toBroadcast(object $notifiable): BroadcastMessage
{
return \Filament\Notifications\Notification::make()
->title('Saved successfully')
->getBroadcastMessage();
}
The Notification is sent using: $user->notify(new OrderCreatedNotification($order)); I attached some screenshots to add more context: * The completed job BroadcastNotificationCreated after broadcasting the Filament Notification * The websocket connection from Chrome dev tools
No description
No description
1 Reply
Veur
VeurOP5mo ago
It works when I add the trait BroadcastsEvents and the broadcastOn() method to the OrderCreatedNotification class:
public function broadcastOn(): array
{
return [
new PrivateChannel('users.1'),
];
}
public function broadcastOn(): array
{
return [
new PrivateChannel('users.1'),
];
}
But this is not documented anywhere in Laravel, so I doubt this really is the correct solution...
Want results from more Discord servers?
Add your server