<?php

namespace App\Models;

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

class ConfigItem extends BaseModel
{
    protected $table = 'config_items';

    public const CREATED_AT = 'create_time';

    public const UPDATED_AT = 'update_time';

    protected $fillable = [
        'group_id',
        'name',
        'code',
        'value',
        'type',
        'options',
        'tips',
        'sort',
        'status',
    ];

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

    public function group(): BelongsTo
    {
        return $this->belongsTo(ConfigGroup::class, 'group_id');
    }
}
