<?php

namespace App\Models;

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

class DocumentTemplateColumn extends Model
{
    use HasFactory;

    protected $fillable = [
        'template_id',
        'label',
        'width',
        'column_type',
        'group_name',
        'sub_labels',
        'sort_order',
    ];

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

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