<?php

namespace App\Modules\Inventory\Models;

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

/**
 * 倉庫-商品安全庫存設定
 * 每個倉庫-商品組合只有一筆安全庫存設定
 */
class WarehouseProductSafetyStock extends Model
{
    protected $table = 'warehouse_product_safety_stocks';

    protected $fillable = [
        'warehouse_id',
        'product_id',
        'safety_stock',
    ];

    protected $casts = [
        'safety_stock' => 'decimal:2',
    ];

    /**
     * 所屬倉庫
     */
    public function warehouse(): BelongsTo
    {
        return $this->belongsTo(Warehouse::class);
    }

    /**
     * 所屬商品
     */
    public function product(): BelongsTo
    {
        return $this->belongsTo(Product::class);
    }
}
