<?php

namespace App\Actions\Schedule;

use App\Events\ModelChanged;
use App\Models\CourseSchedule;
use App\Repositories\Contracts\ScheduleRepositoryInterface;

final class DeleteScheduleAction
{
    public function __construct(private ScheduleRepositoryInterface $repository) {}

    public function execute(CourseSchedule $schedule): bool
    {
        $this->repository->delete($schedule);

        ModelChanged::dispatch(CourseSchedule::class, 'deleted');

        return true;
    }
}
