<?php

namespace App\Notifications;

use App\Models\Event;
use App\Jobs\SendEventReminder;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;

class EventReminderNotification extends Notification
{
    use Queueable;

    public function __construct(
        protected Event $event,
        protected array $reminder,
    ) {}

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

    public function toArray($notifiable): array
    {
        $job = new SendEventReminder($this->event, $this->reminder);

        return [
            'type'     => 'event_reminder',
            'title'    => 'Erinnerung: ' . $this->event->title,
            'message'  => $job->buildMessage(),
            'event_id' => $this->event->id,
        ];
    }
}
