Skip to main content

Real-time — Laravel Reverb

WebSocket-based real-time notifications using Laravel Reverb. Replaces polling with push events for matter assignments, invoice payments, and appointment reminders.


What Uses Real-time

EventTriggered byNotified users
Matter assignedMatterAttorney createdAssigned lawyer
Invoice paidPayment createdBilling admin + matter lead
Appointment reminderScheduled job (1hr before)All attendees
Document uploadedProcessDocumentJob completeMatter team
Comment addedComment createdMatter team

Setup

composer require laravel/reverb
php artisan reverb:install
php artisan reverb:start

Reverb runs as a separate long-running process but uses the same Laravel application code.


Broadcasting a Notification

// app/Notifications/MatterAssignedNotification.php
class MatterAssignedNotification extends Notification implements ShouldBroadcast
{
public function broadcastOn(): array
{
return [new PrivateChannel("user.{$this->userId}")];
}

public function broadcastAs(): string
{
return 'matter.assigned';
}
}

Filament Integration

Filament's DatabaseNotification component polls for unread notifications by default. With Reverb, this is replaced by a WebSocket listener that pushes the unread count to the panel in real time — no polling overhead.


Authentication

Private channels require authentication. The channel auth endpoint is provided by Laravel's broadcasting system:

// routes/channels.php
Broadcast::channel('user.{userId}', function (User $user, int $userId) {
return $user->id === $userId;
});