'date', 'due_date' => 'date', 'receiving_date' => 'date', 'order_qty' => 'decimal:2', 'receiving_qty' => 'decimal:2', 'item_id' => 'integer', ]; /** * 상태 목록 */ public const STATUSES = [ 'order_completed' => '발주완료', 'shipping' => '배송중', 'inspection_pending' => '검사대기', 'receiving_pending' => '입고대기', 'completed' => '입고완료', ]; /** * 품목 관계 */ public function item(): BelongsTo { return $this->belongsTo(\App\Models\Items\Item::class); } /** * 생성자 관계 */ public function creator(): BelongsTo { return $this->belongsTo(\App\Models\Members\User::class, 'created_by'); } /** * 상태 라벨 */ public function getStatusLabelAttribute(): string { return self::STATUSES[$this->status] ?? $this->status; } /** * 수정 가능 여부 */ public function canEdit(): bool { return $this->status !== 'completed'; } /** * 삭제 가능 여부 */ public function canDelete(): bool { return $this->status !== 'completed'; } /** * 입고처리 가능 여부 */ public function canProcess(): bool { return in_array($this->status, ['order_completed', 'shipping', 'inspection_pending', 'receiving_pending']); } }