- ItemsController 및 ItemsService CRUD 메서드 구현 - FormRequest 검증 클래스 추가 (ItemStoreRequest, ItemUpdateRequest) - Swagger 문서 완성 (ItemsApi.php) - 품목 생성/조회/수정/삭제 엔드포인트 추가 - i18n 메시지 키 추가 (message.item) - Code 기반 라우팅 적용 - Hybrid 구조 지원 (고정 필드 + attributes JSON)
61 lines
2.1 KiB
PHP
61 lines
2.1 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 [
|
|
// 필수 필드
|
|
'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',
|
|
];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'code.required' => '품목코드는 필수입니다.',
|
|
'code.max' => '품목코드는 50자 이내로 입력하세요.',
|
|
'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 이상이어야 합니다.',
|
|
];
|
|
}
|
|
}
|