<?php

namespace App\Modules\Inventory\Models;

use App\Modules\Admin\Tenancy\Traits\BelongsToTenant;
use App\Modules\Inventory\Support\InventoryPriceDirection;
use App\Modules\Inventory\Support\InventoryUserStamp;
use App\Modules\Inventory\Support\LogsInventoryCatalogActivity;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

class InventoryPriceType extends Model
{
    use BelongsToTenant;
    use InventoryUserStamp;
    use LogsInventoryCatalogActivity;

    protected $table = 'inventory_price_types';

    protected $fillable = [
        'tenant_id',
        'code',
        'name',
        'direction',
        'is_active',
        'created_by',
        'updated_by',
    ];

    protected function casts(): array
    {
        return [
            'direction' => InventoryPriceDirection::class,
            'is_active' => 'boolean',
        ];
    }

    public function itemPrices(): HasMany
    {
        return $this->hasMany(ItemPrice::class, 'price_type_id');
    }
}
