2026-08-03 13:44:10 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Notifications;
|
|
|
|
|
|
|
|
|
|
use App\Models\Task;
|
|
|
|
|
use Illuminate\Bus\Queueable;
|
2026-08-31 12:16:56 +02:00
|
|
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
2026-08-03 13:44:10 +02:00
|
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
|
|
2026-08-31 12:16:56 +02:00
|
|
|
class TaskOverdueNotification extends Notification implements ShouldBroadcast
|
2026-08-03 13:44:10 +02:00
|
|
|
{
|
|
|
|
|
use Queueable;
|
|
|
|
|
|
|
|
|
|
public function __construct(public Task $task) {}
|
|
|
|
|
|
|
|
|
|
public function via($notifiable): array
|
|
|
|
|
{
|
2026-08-31 12:16:56 +02:00
|
|
|
return ['database', 'broadcast'];
|
2026-08-03 13:44:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function toArray($notifiable): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'type' => 'task_overdue',
|
|
|
|
|
'task_id' => $this->task->id,
|
|
|
|
|
'project_id' => $this->task->project_id,
|
|
|
|
|
'due_date' => $this->task->due_date?->toDateString(),
|
|
|
|
|
'message' => "Tarea vencida: '{$this->task->title}' (venció el {$this->task->due_date?->format('d/m/Y')})",
|
|
|
|
|
];
|
|
|
|
|
}
|
2026-08-31 12:16:56 +02:00
|
|
|
|
|
|
|
|
public function broadcastOn(): array
|
|
|
|
|
{
|
|
|
|
|
return [new \Illuminate\Broadcasting\PrivateChannel('user.'.$this->task->assigned_to)];
|
|
|
|
|
}
|
|
|
|
|
}
|