## 구현 내용 ### 모델 (5개) - QuoteFormulaCategory: 수식 카테고리 - QuoteFormula: 수식 정의 (input/calculation/range/mapping) - QuoteFormulaRange: 범위별 값 정의 - QuoteFormulaMapping: 매핑 테이블 - QuoteFormulaItem: 수식-품목 연결 ### 서비스 (3개) - QuoteFormulaCategoryService: 카테고리 CRUD - QuoteFormulaService: 수식 CRUD, 복제, 재정렬 - FormulaEvaluatorService: 수식 계산 엔진 - 지원 함수: SUM, ROUND, CEIL, FLOOR, ABS, MIN, MAX, IF, AND, OR, NOT ### API Controller (2개) - QuoteFormulaCategoryController: 카테고리 API (11개 엔드포인트) - QuoteFormulaController: 수식 API (16개 엔드포인트) ### FormRequest (4개) - Store/Update QuoteFormulaCategoryRequest - Store/Update QuoteFormulaRequest ### Blade Views (8개) - 수식 목록/추가/수정/시뮬레이터 - 카테고리 목록/추가/수정 - HTMX 테이블 partial ### 라우트 - API: 27개 엔드포인트 - Web: 7개 라우트
71 lines
3.0 KiB
PHP
71 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Quote;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class StoreQuoteFormulaRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return auth()->check();
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'category_id' => 'required|integer|exists:quote_formula_categories,id',
|
|
'product_id' => 'nullable|integer',
|
|
'name' => 'required|string|max:200',
|
|
'variable' => 'required|string|max:50|regex:/^[A-Z][A-Z0-9_]*$/',
|
|
'type' => 'required|in:input,calculation,range,mapping',
|
|
'formula' => 'nullable|string|max:2000',
|
|
'output_type' => 'in:variable,item',
|
|
'description' => 'nullable|string|max:500',
|
|
'sort_order' => 'nullable|integer|min:1',
|
|
'is_active' => 'boolean',
|
|
|
|
// 범위 규칙
|
|
'ranges' => 'array',
|
|
'ranges.*.min_value' => 'nullable|numeric',
|
|
'ranges.*.max_value' => 'nullable|numeric',
|
|
'ranges.*.condition_variable' => 'required_with:ranges|string|max:50',
|
|
'ranges.*.result_value' => 'required_with:ranges|string|max:500',
|
|
'ranges.*.result_type' => 'in:fixed,formula',
|
|
|
|
// 매핑 규칙
|
|
'mappings' => 'array',
|
|
'mappings.*.source_variable' => 'required_with:mappings|string|max:50',
|
|
'mappings.*.source_value' => 'required_with:mappings|string|max:200',
|
|
'mappings.*.result_value' => 'required_with:mappings|string|max:500',
|
|
'mappings.*.result_type' => 'in:fixed,formula',
|
|
|
|
// 품목 출력
|
|
'items' => 'array',
|
|
'items.*.item_code' => 'required_with:items|string|max:50',
|
|
'items.*.item_name' => 'required_with:items|string|max:200',
|
|
'items.*.specification' => 'nullable|string|max:100',
|
|
'items.*.unit' => 'required_with:items|string|max:20',
|
|
'items.*.quantity_formula' => 'required_with:items|string|max:500',
|
|
'items.*.unit_price_formula' => 'nullable|string|max:500',
|
|
];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'category_id.required' => '카테고리를 선택해주세요.',
|
|
'category_id.exists' => '유효하지 않은 카테고리입니다.',
|
|
'name.required' => '수식 이름은 필수입니다.',
|
|
'name.max' => '수식 이름은 200자 이하로 입력해주세요.',
|
|
'variable.required' => '변수명은 필수입니다.',
|
|
'variable.regex' => '변수명은 대문자로 시작하고 대문자, 숫자, 언더스코어만 사용할 수 있습니다.',
|
|
'variable.max' => '변수명은 50자 이하로 입력해주세요.',
|
|
'type.required' => '수식 유형을 선택해주세요.',
|
|
'type.in' => '유효하지 않은 수식 유형입니다.',
|
|
'formula.max' => '수식은 2000자 이하로 입력해주세요.',
|
|
'output_type.in' => '유효하지 않은 출력 유형입니다.',
|
|
];
|
|
}
|
|
}
|