<?php
namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class CategoryField extends Model
{
    use HasFactory, SoftDeletes;

    protected $fillable = [
        'field_id',
        'category_id',
        'type',
        'label',
        'name',
        'label_ar',
        'name_ar',
        'options',
        'attribute_id',
        'file_types',
        'order',
        'required',
        'section',
    ];

    public function category()
    {
        return $this->belongsTo(Category::class);
    }

    public function attribute()
    {
        return $this->belongsTo(CategoryAtributes::class, 'attribute_id');
    }

    public function value()
    {
        return $this->belongsTo(AdField::class, 'field_id');
    }

    public function getOptions()
    {
        return $this->hasMany(CategoryAtributesValue::class, 'attribute_id', 'attribute_id');
    }
}
