<?php

namespace App\Models;

use App\Models\Concerns\BelongsToTenant;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class ScheduleException extends Model
{
    use BelongsToTenant;

    protected $fillable = [
        'tenant_id', 'dentist_id', 'date', 'type',
        'start_time', 'end_time', 'reason',
    ];

    protected function casts(): array
    {
        return ['date' => 'date'];
    }

    public function dentist(): BelongsTo
    {
        return $this->belongsTo(Dentist::class);
    }

    public function isWholeDay(): bool
    {
        return $this->type === 'off' && $this->start_time === null;
    }
}
