40 lines
849 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class StockItem extends Model
{
use HasFactory;
protected $fillable = [
'product_id',
'warehouse_id',
'qty_on_hand_base',
'safety_stock_base',
];
protected $casts = [
'qty_on_hand_base' => 'decimal:3',
'safety_stock_base' => 'decimal:3',
];
/**
* Get the product associated with this stock item.
*/
public function product(): BelongsTo
{
return $this->belongsTo(Product::class);
}
/**
* Get the warehouse where this stock item is located.
*/
public function warehouse(): BelongsTo
{
return $this->belongsTo(Warehouse::class);
}
}