<?php

namespace App\Models\Tenants;

use Illuminate\Database\Eloquent\Model;

/**
 * @mixin IdeHelperTenantFieldSetting
 */
class TenantFieldSetting extends Model
{
    public $timestamps = false;

    protected $casts = [
        'enabled' => 'boolean',
        'required' => 'boolean',
    ];

    protected $fillable = [
        'tenant_id',
        'field_key',
        'enabled',
        'required',
        'sort_order',
        'option_group_id',
        'code_group',
    ];

    public function fieldDef()
    {
        return $this->belongsTo(SettingFieldDef::class, 'field_key', 'field_key');
    }

    public function optionGroup()
    {
        return $this->belongsTo(TenantOptionGroup::class, 'option_group_id');
    }
}
