<?php

namespace App\Domain\HR\Models;

use App\Domain\HR\Enums\AvailabilityType;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use App\Domain\Shared\Traits\ScopedThroughBranch;

class TrainerAvailability extends Model
{
    use ScopedThroughBranch;

    /**
     * The parent whose branch this row inherits. A line item has no
     * branch of its own and must not grow one — a denormalised copy
     * here is a second source of truth that drifts the first time the
     * parent moves.
     */
    protected static string $branchScopeRelation = 'trainer';

    public $timestamps = false;

    const CREATED_AT = 'created_at';
    const UPDATED_AT = null;

    protected $table = 'trainer_availability';

    protected $fillable = [
        'trainer_id',
        'type',
        'day_of_week',
        'specific_date',
        'start_time',
        'end_time',
        'reason',
    ];

    protected $casts = [
        'type' => AvailabilityType::class,
        'specific_date' => 'date',
        'day_of_week' => 'integer',
    ];

    // --- Relationships ---

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