47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Modules\MaterialLogistics\Models;
|
|
|
|
use App\Traits\HasPublicIdentifier;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Modules\MasterData\Models\Material;
|
|
|
|
class InventoryBatch extends Model
|
|
{
|
|
use HasPublicIdentifier;
|
|
|
|
protected $fillable = [
|
|
'warehouse_id', 'material_id', 'material_requisition_id', 'purchase_order_id',
|
|
'quantity', 'unit_cost',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'quantity' => 'decimal:2',
|
|
'unit_cost' => 'decimal:2',
|
|
];
|
|
}
|
|
|
|
public function warehouse(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Warehouse::class);
|
|
}
|
|
|
|
public function material(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Material::class);
|
|
}
|
|
|
|
public function requisition(): BelongsTo
|
|
{
|
|
return $this->belongsTo(MaterialRequisition::class, 'material_requisition_id');
|
|
}
|
|
|
|
public function purchaseOrder(): BelongsTo
|
|
{
|
|
return $this->belongsTo(PurchaseOrder::class, 'purchase_order_id');
|
|
}
|
|
}
|