<?php

namespace App\Models\Warehouse;

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

class ReplenishmentOrderItem extends Model
{
    use HasFactory;

    protected $fillable = [
        'replenishment_order_id',
        'product_id',
        'slot_no',
        'quantity',
        'current_stock',
        'max_stock',
    ];

    protected $casts = [
        'quantity' => 'integer',
        'current_stock' => 'integer',
        'max_stock' => 'integer',
    ];

    /**
     * 所屬補貨單
     */
    public function replenishmentOrder()
    {
        return $this->belongsTo(ReplenishmentOrder::class);
    }

    /**
     * 對應商品
     */
    public function product()
    {
        return $this->belongsTo(\App\Models\Product\Product::class);
    }
}
