<?php

namespace App\Notifications;

use App\Models\Task;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;

class TaskDueSoonNotification extends Notification
{
    use Queueable;

    public function __construct(protected Task $task) {}

    public function via($notifiable): array
    {
        return ['database'];
    }

    public function toArray($notifiable): array
    {
        $dueDate = $this->task->due_date->format('M j, g:i A');

        return [
            'title' => 'Task Due Soon',
            'message' => "\"{$this->task->title}\" is due on {$dueDate}",
            'url' => route('tasks.show', $this->task->id),
            'task_id' => $this->task->id,
            'project_id' => $this->task->project_id,
        ];
    }
}
