<?php

namespace App\Notifications;

use App\Models\Event;
use Illuminate\Notifications\Messages\MailMessage;

class EventReminderNotification extends BaseSchoolNotification
{
    public function __construct(public Event $event) {}

    public function toMail(object $notifiable): MailMessage
    {
        return $this->mailMessage(
            subject: 'Upcoming event: '.$this->event->title,
            greeting: 'Hello '.$notifiable->name.',',
            line: "{$this->event->title} is on {$this->event->starts_at?->format('l, d M Y \\a\\t H:i')} at ".($this->event->location ?? 'TBC').'.',
            actionUrl: url('/dashboard'),
            actionText: 'View Details',
        );
    }

    /**
     * @return array<string, mixed>
     */
    public function toArray(object $notifiable): array
    {
        return $this->databasePayload(
            title: 'Event reminder',
            body: "{$this->event->title} — {$this->event->starts_at?->format('d M Y H:i')}",
            type: 'event',
            url: '/dashboard',
        );
    }
}
