- 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)
37 lines
1.0 KiB
PHP
37 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use App\Models\IssueTask;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class IssueTaskAssignedNotification extends Notification implements ShouldBroadcast
|
|
{
|
|
use Queueable;
|
|
|
|
public function __construct(public IssueTask $task) {}
|
|
|
|
public function via($notifiable): array
|
|
{
|
|
return ['database', 'broadcast'];
|
|
}
|
|
|
|
public function toArray($notifiable): array
|
|
{
|
|
return [
|
|
'type' => 'issue_task_assigned',
|
|
'issue_id' => $this->task->issue_id,
|
|
'task_id' => $this->task->id,
|
|
'project_id' => $this->task->issue?->project_id,
|
|
'due_date' => $this->task->due_date?->toDateString(),
|
|
'message' => "Se te ha asignado la tarea '{$this->task->title}'",
|
|
];
|
|
}
|
|
|
|
public function broadcastOn(): array
|
|
{
|
|
return [new \Illuminate\Broadcasting\PrivateChannel('user.'.$this->task->assigned_to)];
|
|
}
|
|
} |