<?php

declare(strict_types=1);

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;

class ClassScheduleException extends Model
{
    use SoftDeletes;

    protected $table = 'class_schedule_exceptions';

    protected $fillable = [
        'venue_id',
        'schedule_id',
        'date',
        'action',
        'course_id',
        'start_time',
        'end_time',
        'classroom',
        'class_title',
        'coach_id',
        'coach_display_name',
        'location',
        'level',
        'note',
        'sort_order',
        'is_active',
    ];

    protected function casts(): array
    {
        return [
            'venue_id' => 'int',
            'schedule_id' => 'int',
            'course_id' => 'int',
            'coach_id' => 'int',
            'date' => 'date',
            'sort_order' => 'int',
            'is_active' => 'bool',
        ];
    }

    public function venue(): BelongsTo
    {
        return $this->belongsTo(Venue::class, 'venue_id');
    }

    public function schedule(): BelongsTo
    {
        return $this->belongsTo(ClassSchedule::class, 'schedule_id');
    }

    public function course(): BelongsTo
    {
        return $this->belongsTo(ClassCourse::class, 'course_id');
    }

    public function coach(): BelongsTo
    {
        return $this->belongsTo(Coach::class, 'coach_id');
    }
}
