<?php

namespace App\Models;

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

class ItemWarehouse extends Model
{
    use HasFactory;

    // Explicit table name
    protected $table = 'itemwarehouse';

    // Mass-assignable fields
    protected $fillable = [
        'item_id',
        'warehouse_id',
        'quantity',
    ];

    /*
    |--------------------------------------------------------------------------
    | Relationships
    |--------------------------------------------------------------------------
    */

    // Each ItemWarehouse belongs to one "item" in price_listing_setups1
    public function item()
    {
        return $this->belongsTo(PriceListingSetup1::class, 'item_id');
    }

    // Each ItemWarehouse belongs to one warehouse
    public function warehouse()
    {
        return $this->belongsTo(Warehouse::class, 'warehouse_id');
    }
}
