<?php

namespace App\Models\Documents;

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

/**
 * 템플릿 레벨 연결 값 (기존 linked_item_ids/linked_process_id 대체)
 */
class DocumentTemplateLinkValue extends Model
{
    protected $table = 'document_template_link_values';

    public $timestamps = false;

    protected $fillable = [
        'template_id',
        'link_id',
        'linkable_id',
        'sort_order',
        'created_at',
    ];

    protected $casts = [
        'sort_order' => 'integer',
    ];

    public function template(): BelongsTo
    {
        return $this->belongsTo(DocumentTemplate::class, 'template_id');
    }

    public function link(): BelongsTo
    {
        return $this->belongsTo(DocumentTemplateLink::class, 'link_id');
    }
}
