<?php

namespace App\Models;

use App\Enums\Status;
use App\Models\BaseModel;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class ContentModelField extends BaseModel
{
    protected $table = 'content_model_fields';

    public const CREATED_AT = 'create_time';

    public const UPDATED_AT = 'update_time';

    protected $fillable = [
        'model_id',
        'name',
        'field',
        'type',
        'length',
        'decimal_precision',
        'default_value',
        'form_type',
        'form_config',
        'sort',
        'status',
    ];

    protected $casts = [
        'form_config' => 'array',
        'status' => Status::class,
    ];

    public function model(): BelongsTo
    {
        return $this->belongsTo(ContentModel::class, 'model_id');
    }
}
