55 lines
1.9 KiB
PHP
55 lines
1.9 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Requests\Item;
|
||
|
|
|
||
|
|
use Illuminate\Foundation\Http\FormRequest;
|
||
|
|
|
||
|
|
class ItemUpdateRequest extends FormRequest
|
||
|
|
{
|
||
|
|
public function authorize(): bool
|
||
|
|
{
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function rules(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
// 선택 필드 (모두 sometimes)
|
||
|
|
'code' => 'sometimes|string|max:50',
|
||
|
|
'name' => 'sometimes|string|max:255',
|
||
|
|
'product_type' => 'sometimes|string|in:FG,PT,SM,RM,CS',
|
||
|
|
'unit' => 'sometimes|string|max:20',
|
||
|
|
'category_id' => 'nullable|integer|exists:categories,id',
|
||
|
|
'description' => 'nullable|string',
|
||
|
|
|
||
|
|
// 플래그
|
||
|
|
'is_sellable' => 'sometimes|boolean',
|
||
|
|
'is_purchasable' => 'sometimes|boolean',
|
||
|
|
'is_producible' => 'sometimes|boolean',
|
||
|
|
|
||
|
|
// 하이브리드 고정 필드
|
||
|
|
'safety_stock' => 'sometimes|integer|min:0',
|
||
|
|
'lead_time' => 'sometimes|integer|min:0',
|
||
|
|
'is_variable_size' => 'sometimes|boolean',
|
||
|
|
'product_category' => 'sometimes|string|max:20',
|
||
|
|
'part_type' => 'sometimes|string|max:20',
|
||
|
|
|
||
|
|
// 동적 필드 (JSON)
|
||
|
|
'attributes' => 'sometimes|array',
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
public function messages(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'code.max' => '품목코드는 50자 이내로 입력하세요.',
|
||
|
|
'name.max' => '품목명은 255자 이내로 입력하세요.',
|
||
|
|
'product_type.in' => '품목 유형은 FG, PT, SM, RM, CS 중 하나여야 합니다.',
|
||
|
|
'unit.max' => '단위는 20자 이내로 입력하세요.',
|
||
|
|
'category_id.exists' => '존재하지 않는 카테고리입니다.',
|
||
|
|
'safety_stock.min' => '안전재고는 0 이상이어야 합니다.',
|
||
|
|
'lead_time.min' => '리드타임은 0 이상이어야 합니다.',
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|