feat: Phase 2 - Laravel Reverb + real-time notifications

- Install laravel/reverb + laravel-echo + pusher-js
- Configure broadcasting to reverb in .env.example + .env
- Add Echo + Pusher client in resources/js/app.js
- Update all 14 notifications to implement ShouldBroadcast + broadcastOn()
- Update NotificationBell component to listen for real-time events
- Add Livewire.emit in notification-bell blade for JS-to-Livewire bridge

Tests: 101 passing (319 assertions)
This commit is contained in:
Javier Braña
2026-08-31 12:16:56 +02:00
parent 78d1dbf45a
commit 9222eefdf9
26 changed files with 1192 additions and 44 deletions
@@ -4,9 +4,10 @@ namespace App\Notifications;
use App\Models\Inspection;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Notifications\Notification;
class InspectionUpdatedNotification extends Notification
class InspectionUpdatedNotification extends Notification implements ShouldBroadcast
{
use Queueable;
@@ -14,7 +15,7 @@ class InspectionUpdatedNotification extends Notification
public function via($notifiable): array
{
return ['database'];
return ['database', 'broadcast'];
}
public function toArray($notifiable): array
@@ -30,4 +31,10 @@ class InspectionUpdatedNotification extends Notification
'message' => "Inspección actualizada en '{$this->inspection->feature?->name}'",
];
}
}
public function broadcastOn(): array
{
$userIds = $this->inspection->project->users->pluck('id')->toArray();
return array_map(fn ($id) => new \Illuminate\Broadcasting\PrivateChannel("user.{$id}"), $userIds);
}
}