## Critical 수정 - Multi-tenancy: WorkOrderItem, BendingDetail, Issue에 BelongsToTenant 적용 - 감사 로그: 상태변경, 품목수정, 이슈 등록/해결 시 로깅 추가 - 상태 전이 규칙: STATUS_TRANSITIONS + canTransitionTo() 구현 ## High 수정 - 다중 담당자: work_order_assignees 피벗 테이블 및 관계 추가 - 부분 수정: 품목 ID 기반 upsert/delete 로직 구현 ## 변경 파일 - Models: WorkOrder, WorkOrderAssignee(신규), 하위 모델들 - Services: WorkOrderService (assign, update 메서드 개선) - Migrations: tenant_id 추가, assignees 테이블 생성 Co-Authored-By: Claude <noreply@anthropic.com>
67 lines
1.8 KiB
PHP
67 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Production;
|
|
|
|
use App\Models\Items\Item;
|
|
use App\Traits\BelongsToTenant;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* 작업지시 품목 모델
|
|
*/
|
|
class WorkOrderItem extends Model
|
|
{
|
|
use BelongsToTenant;
|
|
|
|
protected $table = 'work_order_items';
|
|
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'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');
|
|
}
|
|
}
|