Files
sam-api/app/Models/Production/WorkOrderMaterialInput.php
권혁성 4dd38ab14d feat: [생산지시] 전용 API + 자재투입/공정 개선
- ProductionOrder 전용 엔드포인트 (목록/통계/상세)
- 재고생산 보조공정 일반 워크플로우에서 분리
- 자재투입 replace 모드 + bom_group_key 개별 저장
- 공정단계 options 컬럼 추가 (검사 설정/범위)
- 셔터박스 prefix isStandard 파라미터 제거

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 02:57:59 +09:00

105 lines
2.7 KiB
PHP

<?php
namespace App\Models\Production;
use App\Models\Items\Item;
use App\Models\Members\User;
use App\Models\Tenants\StockLot;
use App\Traits\Auditable;
use App\Traits\BelongsToTenant;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* 개소별 자재 투입 이력 모델
*
* 작업지시 품목(개소)별 자재 투입을 추적
*/
class WorkOrderMaterialInput extends Model
{
use Auditable, BelongsToTenant;
protected $table = 'work_order_material_inputs';
protected $fillable = [
'tenant_id',
'work_order_id',
'work_order_item_id',
'stock_lot_id',
'item_id',
'bom_group_key',
'qty',
'input_by',
'input_at',
];
protected $casts = [
'qty' => 'decimal:3',
'input_at' => 'datetime',
];
// ──────────────────────────────────────────────────────────────
// 관계
// ──────────────────────────────────────────────────────────────
/**
* 작업지시
*/
public function workOrder(): BelongsTo
{
return $this->belongsTo(WorkOrder::class);
}
/**
* 작업지시 품목 (개소)
*/
public function workOrderItem(): BelongsTo
{
return $this->belongsTo(WorkOrderItem::class);
}
/**
* 투입 로트
*/
public function stockLot(): BelongsTo
{
return $this->belongsTo(StockLot::class);
}
/**
* 자재 품목
*/
public function item(): BelongsTo
{
return $this->belongsTo(Item::class);
}
/**
* 투입자
*/
public function inputBy(): BelongsTo
{
return $this->belongsTo(User::class, 'input_by');
}
// ──────────────────────────────────────────────────────────────
// 스코프
// ──────────────────────────────────────────────────────────────
/**
* 특정 개소의 투입 이력
*/
public function scopeForItem($query, int $workOrderItemId)
{
return $query->where('work_order_item_id', $workOrderItemId);
}
/**
* 특정 자재의 투입 이력
*/
public function scopeForMaterial($query, int $itemId)
{
return $query->where('item_id', $itemId);
}
}