63 lines
1.7 KiB
PHP
63 lines
1.7 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Models\Production;
|
||
|
|
|
||
|
|
use App\Models\Items\Item;
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 작업지시 품목 모델
|
||
|
|
*/
|
||
|
|
class WorkOrderItem extends Model
|
||
|
|
{
|
||
|
|
protected $table = 'work_order_items';
|
||
|
|
|
||
|
|
protected $fillable = [
|
||
|
|
'work_order_id',
|
||
|
|
'item_id',
|
||
|
|
'item_name',
|
||
|
|
'specification',
|
||
|
|
'quantity',
|
||
|
|
'unit',
|
||
|
|
'sort_order',
|
||
|
|
];
|
||
|
|
|
||
|
|
protected $casts = [
|
||
|
|
'quantity' => 'decimal:2',
|
||
|
|
'sort_order' => 'integer',
|
||
|
|
];
|
||
|
|
|
||
|
|
// ──────────────────────────────────────────────────────────────
|
||
|
|
// 관계
|
||
|
|
// ──────────────────────────────────────────────────────────────
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 작업지시
|
||
|
|
*/
|
||
|
|
public function workOrder(): BelongsTo
|
||
|
|
{
|
||
|
|
return $this->belongsTo(WorkOrder::class);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 품목
|
||
|
|
*/
|
||
|
|
public function item(): BelongsTo
|
||
|
|
{
|
||
|
|
return $this->belongsTo(Item::class);
|
||
|
|
}
|
||
|
|
|
||
|
|
// ──────────────────────────────────────────────────────────────
|
||
|
|
// 스코프
|
||
|
|
// ──────────────────────────────────────────────────────────────
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 정렬 순서
|
||
|
|
*/
|
||
|
|
public function scopeOrdered($query)
|
||
|
|
{
|
||
|
|
return $query->orderBy('sort_order');
|
||
|
|
}
|
||
|
|
}
|