<?php

namespace App\Models\Sale;

use App\Models\Agency\Agency;
use Illuminate\Database\Eloquent\Model;

class SaleFieldDefinition extends Model
{
    protected $table = 'sale_field_definitions';

    protected $fillable = [
        'agency_id',
        'field_key',
        'label',
        'field_type',
        'options',
        'is_required',
        'is_active',
        'sort_order',
    ];

    protected $casts = [
        'options' => 'array',
        'is_required' => 'boolean',
        'is_active' => 'boolean',
    ];

    public function agency()
    {
        return $this->belongsTo(Agency::class);
    }

    public function values()
    {
        return $this->hasMany(SaleFieldValue::class, 'field_definition_id');
    }
}
