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 TaskAssignedNotification 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_assigned',
|
|
|
|
|
'task_id' => $this->task->id,
|
|
|
|
|
'project_id' => $this->task->project_id,
|
|
|
|
|
'priority' => $this->task->priority,
|
|
|
|
|
'message' => "Se te ha asignado la tarea '{$this->task->title}'",
|
|
|
|
|
];
|
|
|
|
|
}
|
2026-08-31 12:16:56 +02:00
|
|
|
|
|
|
|
|
public function broadcastOn(): array
|
|
|
|
|
{
|
|
|
|
|
return [new \Illuminate\Broadcasting\PrivateChannel('user.'.$this->task->assigned_to)];
|
|
|
|
|
}
|
|
|
|
|
}
|