<?php

namespace App\Models;

use App\Models\BaseModel;
use Illuminate\Database\Eloquent\SoftDeletes;

class DimensionValue extends BaseModel
{
    use SoftDeletes;

    protected $fillable = [
        'company_id','dimension_id','parent_id','code','name',
        'is_active','sort_order','depth','path'
    ];

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

    public function dimension()
    {
        return $this->belongsTo(Dimension::class);
    }

    public function parent()
    {
        return $this->belongsTo(DimensionValue::class, 'parent_id');
    }

    public function children()
    {
        return $this->hasMany(DimensionValue::class, 'parent_id');
    }
}
