- FormRequest에 manufacturer, material_no 규칙 추가 (validated()에서 누락 방지) - store() 시 lot_no 자동 생성 (generateLotNo() 폴백) - getOrCreateStock()에서 item_code 기반 2차 검색 추가 (unique key 충돌 방지) - 동일 item_code, 다른 item_id인 Stock 존재 시 item_id 업데이트 - SoftDeletes 복원 로직 포함 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
49 lines
2.0 KiB
PHP
49 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\V1\Receiving;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class StoreReceivingRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'order_no' => ['nullable', 'string', 'max:30'],
|
|
'order_date' => ['nullable', 'date'],
|
|
'item_id' => ['nullable', 'integer'],
|
|
'item_code' => ['required', 'string', 'max:50'],
|
|
'item_name' => ['required', 'string', 'max:200'],
|
|
'specification' => ['nullable', 'string', 'max:200'],
|
|
'supplier' => ['required', 'string', 'max:100'],
|
|
'order_qty' => ['nullable', 'numeric', 'min:0'],
|
|
'order_unit' => ['nullable', 'string', 'max:20'],
|
|
'due_date' => ['nullable', 'date'],
|
|
'receiving_qty' => ['nullable', 'numeric', 'min:0'],
|
|
'receiving_date' => ['nullable', 'date'],
|
|
'lot_no' => ['nullable', 'string', 'max:50'],
|
|
'status' => ['nullable', 'string', 'in:order_completed,shipping,inspection_pending,receiving_pending'],
|
|
'remark' => ['nullable', 'string', 'max:1000'],
|
|
'manufacturer' => ['nullable', 'string', 'max:100'],
|
|
'material_no' => ['nullable', 'string', 'max:50'],
|
|
];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'item_code.required' => __('validation.required', ['attribute' => '품목코드']),
|
|
'item_name.required' => __('validation.required', ['attribute' => '품목명']),
|
|
'supplier.required' => __('validation.required', ['attribute' => '공급업체']),
|
|
'order_qty.required' => __('validation.required', ['attribute' => '발주수량']),
|
|
'order_qty.numeric' => __('validation.numeric', ['attribute' => '발주수량']),
|
|
'order_qty.min' => __('validation.min.numeric', ['attribute' => '발주수량', 'min' => 0]),
|
|
];
|
|
}
|
|
}
|