- Migration: nonconforming_reports, nonconforming_report_items 테이블 - Model: NonconformingReport, NonconformingReportItem (관계, cast, scope) - FormRequest: Store/Update 검증 (items 배열 포함) - Service: CRUD + 채번(NC-YYYYMMDD-NNN) + 비용 자동 계산 + 상태 전이 - Controller: REST 7개 엔드포인트 (목록/통계/상세/등록/수정/삭제/상태변경) - Route: /api/v1/material/nonconforming-reports - i18n: 부적합관리 에러 메시지 (ko)
46 lines
985 B
PHP
46 lines
985 B
PHP
<?php
|
|
|
|
namespace App\Models\Materials;
|
|
|
|
use App\Models\Items\Item;
|
|
use App\Traits\BelongsToTenant;
|
|
use App\Traits\ModelTrait;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class NonconformingReportItem extends Model
|
|
{
|
|
use BelongsToTenant, ModelTrait;
|
|
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'nonconforming_report_id',
|
|
'item_id',
|
|
'item_name',
|
|
'specification',
|
|
'quantity',
|
|
'unit_price',
|
|
'amount',
|
|
'sort_order',
|
|
'remarks',
|
|
'options',
|
|
];
|
|
|
|
protected $casts = [
|
|
'options' => 'array',
|
|
'quantity' => 'decimal:2',
|
|
'unit_price' => 'integer',
|
|
'amount' => 'integer',
|
|
];
|
|
|
|
public function report(): BelongsTo
|
|
{
|
|
return $this->belongsTo(NonconformingReport::class, 'nonconforming_report_id');
|
|
}
|
|
|
|
public function item(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Item::class);
|
|
}
|
|
}
|