2026-06-18 12:51:41 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Notifications;
|
|
|
|
|
|
|
|
|
|
use App\Models\IssueTask;
|
|
|
|
|
use Illuminate\Bus\Queueable;
|
2026-08-31 12:16:56 +02:00
|
|
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
2026-06-18 12:51:41 +02:00
|
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
|
|
2026-08-31 12:16:56 +02:00
|
|
|
class IssueTaskAssignedNotification extends Notification implements ShouldBroadcast
|
2026-06-18 12:51:41 +02:00
|
|
|
{
|
|
|
|
|
use Queueable;
|
|
|
|
|
|
|
|
|
|
public function __construct(public IssueTask $task) {}
|
|
|
|
|
|
|
|
|
|
public function via($notifiable): array
|
|
|
|
|
{
|
2026-08-31 12:16:56 +02:00
|
|
|
return ['database', 'broadcast'];
|
2026-06-18 12:51:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function toArray($notifiable): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
2026-08-28 13:04:28 +02:00
|
|
|
'type' => 'issue_task_assigned',
|
|
|
|
|
'issue_id' => $this->task->issue_id,
|
|
|
|
|
'task_id' => $this->task->id,
|
2026-06-18 12:51:41 +02:00
|
|
|
'project_id' => $this->task->issue?->project_id,
|
2026-08-28 13:04:28 +02:00
|
|
|
'due_date' => $this->task->due_date?->toDateString(),
|
|
|
|
|
'message' => "Se te ha asignado la tarea '{$this->task->title}'",
|
2026-06-18 12:51:41 +02:00
|
|
|
];
|
|
|
|
|
}
|
2026-08-31 12:16:56 +02:00
|
|
|
|
|
|
|
|
public function broadcastOn(): array
|
|
|
|
|
{
|
|
|
|
|
return [new \Illuminate\Broadcasting\PrivateChannel('user.'.$this->task->assigned_to)];
|
|
|
|
|
}
|
|
|
|
|
}
|