- ItemTypeHelper를 활용한 item_type(FG/PT/SM/RM/CS) → source_table 매핑 - getItem: item_type 파라미터로 products/materials 테이블 자동 결정 - deleteItem: item_type 필수 파라미터 추가 - batchDeleteItems: item_type별 일괄 삭제 지원 - 목록 조회 시 attributes 플랫 전개 - Swagger 문서 업데이트
71 lines
2.6 KiB
PHP
71 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Item;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class ItemStoreRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
// 필수 필드 (중복 시 Service에서 자동 증가 처리)
|
|
'code' => 'required|string|max:50',
|
|
'name' => 'required|string|max:255',
|
|
'product_type' => 'required|string|in:FG,PT,SM,RM,CS',
|
|
'unit' => 'required|string|max:20',
|
|
|
|
// 선택 필드
|
|
'category_id' => 'nullable|integer|exists:categories,id',
|
|
'description' => 'nullable|string',
|
|
|
|
// 플래그
|
|
'is_sellable' => 'nullable|boolean',
|
|
'is_purchasable' => 'nullable|boolean',
|
|
'is_producible' => 'nullable|boolean',
|
|
|
|
// 하이브리드 고정 필드
|
|
'safety_stock' => 'nullable|integer|min:0',
|
|
'lead_time' => 'nullable|integer|min:0',
|
|
'is_variable_size' => 'nullable|boolean',
|
|
'product_category' => 'nullable|string|max:20',
|
|
'part_type' => 'nullable|string|max:20',
|
|
|
|
// 동적 필드 (JSON)
|
|
'attributes' => 'nullable|array',
|
|
|
|
// Material 전용 필드
|
|
'material_code' => 'nullable|string|max:50',
|
|
'item_name' => 'nullable|string|max:255',
|
|
'specification' => 'nullable|string|max:255',
|
|
'is_inspection' => 'nullable|string|in:Y,N',
|
|
'search_tag' => 'nullable|string|max:255',
|
|
'remarks' => 'nullable|string',
|
|
'options' => 'nullable|array',
|
|
];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'code.required' => '품목코드는 필수입니다.',
|
|
'code.max' => '품목코드는 50자 이내로 입력하세요.',
|
|
'code.unique' => '이미 사용 중인 품목코드입니다.',
|
|
'name.required' => '품목명은 필수입니다.',
|
|
'name.max' => '품목명은 255자 이내로 입력하세요.',
|
|
'product_type.required' => '품목 유형은 필수입니다.',
|
|
'product_type.in' => '품목 유형은 FG, PT, SM, RM, CS 중 하나여야 합니다.',
|
|
'unit.required' => '단위는 필수입니다.',
|
|
'unit.max' => '단위는 20자 이내로 입력하세요.',
|
|
'category_id.exists' => '존재하지 않는 카테고리입니다.',
|
|
'safety_stock.min' => '안전재고는 0 이상이어야 합니다.',
|
|
'lead_time.min' => '리드타임은 0 이상이어야 합니다.',
|
|
];
|
|
}
|
|
}
|