|string> */ public function rules(): array { $fileType = $this->route('type') ?? $this->input('type'); $rules = [ 'type' => ['sometimes', 'required', 'string', 'in:bending_diagram,specification,certification'], ]; // 파일 타입별 검증 규칙 if ($fileType === 'bending_diagram') { $rules['file'] = [ 'required', 'file', 'mimes:jpg,jpeg,png,gif,bmp,svg,webp', 'max:10240', // 10MB ]; } else { // specification, certification - 문서 파일 $rules['file'] = [ 'required', 'file', 'mimes:pdf,doc,docx,xls,xlsx,hwp', 'max:20480', // 20MB ]; } // 인증 정보 (certification 타입일 때만) if ($fileType === 'certification') { $rules['certification_number'] = ['sometimes', 'nullable', 'string', 'max:50']; $rules['certification_start_date'] = ['sometimes', 'nullable', 'date']; $rules['certification_end_date'] = ['sometimes', 'nullable', 'date', 'after_or_equal:certification_start_date']; } // 절곡 상세 정보 (bending_diagram 타입일 때만) if ($fileType === 'bending_diagram') { $rules['bending_details'] = ['sometimes', 'nullable', 'array']; $rules['bending_details.*.angle'] = ['required_with:bending_details', 'numeric']; $rules['bending_details.*.length'] = ['required_with:bending_details', 'numeric']; $rules['bending_details.*.type'] = ['required_with:bending_details', 'string']; } return $rules; } /** * Get custom attributes for validator errors. * * @return array */ public function attributes(): array { return [ 'type' => '파일 타입', 'file' => '파일', 'certification_number' => '인증번호', 'certification_start_date' => '인증 시작일', 'certification_end_date' => '인증 종료일', 'bending_details' => '절곡 상세 정보', 'bending_details.*.angle' => '절곡 각도', 'bending_details.*.length' => '절곡 길이', 'bending_details.*.type' => '절곡 타입', ]; } /** * Get custom messages for validator errors. * * @return array */ public function messages(): array { return [ 'type.in' => '파일 타입은 bending_diagram, specification, certification 중 하나여야 합니다.', 'file.required' => '파일을 선택해주세요.', 'file.mimes' => '허용되지 않는 파일 형식입니다.', 'file.max' => '파일 크기가 너무 큽니다.', 'certification_end_date.after_or_equal' => '인증 종료일은 시작일 이후여야 합니다.', ]; } }