<?php

namespace Kylin\LawCase\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;

/**
 * 日程提醒通知
 */
class ScheduleReminderNotification extends Notification
{
    use Queueable;

    public function __construct(
        public int $scheduleId,
        public int $daysBefore = 0
    ) {}

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

    public function toArray(object $notifiable): array
    {
        $urgency = match (true) {
            $this->daysBefore <= 1 => 'urgent',
            $this->daysBefore <= 3 => 'high',
            $this->daysBefore <= 7 => 'medium',
            default => 'low',
        };

        return [
            'schedule_id' => $this->scheduleId,
            'days_before' => $this->daysBefore,
            'urgency' => $urgency,
            'message' => $this->daysBefore === 0
                ? '您有一个日程即将开始'
                : "您有一个日程将在{$this->daysBefore}天后开始",
        ];
    }
}
