Files
star-erp/app/Models/ProductionOrderItem.php

48 lines
892 B
PHP
Raw Normal View History

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class ProductionOrderItem extends Model
{
use HasFactory;
protected $fillable = [
'production_order_id',
'inventory_id',
'quantity_used',
'unit_id',
];
protected $casts = [
'quantity_used' => 'decimal:4',
];
/**
* 所屬生產工單
*/
public function productionOrder(): BelongsTo
{
return $this->belongsTo(ProductionOrder::class);
}
/**
* 使用的庫存紀錄
*/
public function inventory(): BelongsTo
{
return $this->belongsTo(Inventory::class);
}
/**
* 單位
*/
public function unit(): BelongsTo
{
return $this->belongsTo(Unit::class);
}
}