<?php

namespace App\Models;

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

/** Catalog binding: pathway → template_code (resolve is_current at assessment start). */
class PathwayTemplate extends Model
{
    public const PHASE_ACUTE = 'acute';

    public const PHASE_FOLLOW_UP = 'follow_up';

    public const PHASE_ANY = 'any';

    protected $table = 'care_pathway_templates';

    protected $fillable = [
        'pathway_id', 'template_code', 'is_required_on_activation', 'phase', 'sort_order',
    ];

    protected function casts(): array
    {
        return [
            'is_required_on_activation' => 'boolean',
            'sort_order' => 'integer',
        ];
    }

    public function pathway(): BelongsTo
    {
        return $this->belongsTo(ClinicalPathway::class, 'pathway_id');
    }
}
