<?php

namespace Functional\Programs\Models;

use Functional\Programs\Database\Factories\ProgramSlotFactory;
use Functional\Routines\Models\Routine;
use Illuminate\Database\Eloquent\Attributes\UseFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
 * Une case du planning d'un programme : semaine/jour, optionnellement liée à une routine.
 *
 * @property int $week
 * @property int $weekday
 * @property string|null $label
 */
#[UseFactory(ProgramSlotFactory::class)]
class ProgramSlot extends Model
{
    use HasFactory;

    protected $fillable = [
        'program_id', 'week', 'weekday', 'routine_id', 'label',
    ];

    protected $casts = [
        'week' => 'integer',
        'weekday' => 'integer',
    ];

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

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