<?php

namespace App\Models;

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

class ProductStock extends Model
{
    /**
     * The table associated with the model.
     * This model maps to the 'inventory' table.
     */
    protected $table = 'inventory';

    protected $fillable = [
        'product_id',
        'branch_id',
        'location_id',
        'quantity',
        'avg_cost',
    ];

    protected $casts = [
        'quantity' => 'integer',
        'avg_cost' => 'decimal:2',
    ];

    public function product(): BelongsTo
    {
        return $this->belongsTo(Product::class);
    }

    public function branch(): BelongsTo
    {
        return $this->belongsTo(Branch::class);
    }

    public function location(): BelongsTo
    {
        return $this->belongsTo(Location::class);
    }
}
