<?php

namespace App\Notifications;

use App\Models\Ticket;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;

class TicketAutoClosedNotification extends Notification implements ShouldQueue
{
    use Queueable;

    public function __construct(private readonly Ticket $ticket)
    {
    }

    public function via(object $notifiable): array
    {
        return ['database'];
    }

    public function toArray(object $notifiable): array
    {
        return [
            'type' => 'ticket_auto_closed',
            'ticket_id' => $this->ticket->id,
            'order_id' => $this->ticket->order_id,
            'subject' => $this->ticket->subject,
            'status' => $this->ticket->status,
            'title' => 'Ticket auto-closed',
            'message' => 'Ticket #' . $this->ticket->id . ' was auto-closed due to no response.',
            'url' => route('customer.tickets.show', $this->ticket),
        ];
    }
}

