<?php

namespace App\Modules\Inventory\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class InventoryCategoryAttribute extends Model
{
    protected $table = 'inventory_category_attributes';

    protected $fillable = [
        'category_id',
        'attribute_id',
        'is_required',
        'sort_order',
        'default_payload',
    ];

    protected function casts(): array
    {
        return [
            'is_required' => 'boolean',
            'default_payload' => 'array',
        ];
    }

    public function category(): BelongsTo
    {
        return $this->belongsTo(ItemCategory::class, 'category_id');
    }

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