<?php

namespace Kylin\LawCase\Listeners;

use Kylin\LawCase\Events\ScheduleReminder;
use Kylin\LawCase\Jobs\SendScheduleReminderJob;

/**
 * 发送日程提醒监听器
 *
 * 监听日程提醒事件，异步发送提醒。
 */
class SendScheduleReminder
{
    public function handle(ScheduleReminder $event): void
    {
        $schedule = $event->schedule;

        if ($schedule->user) {
            SendScheduleReminderJob::dispatch(
                $schedule->user,
                $schedule,
                $event->daysBefore
            );
        }
    }
}
