From 9bceaab8a33c16a8eff23e21c35d144eb120c3db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=84=B1?= Date: Wed, 28 Jan 2026 21:14:30 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=AC=B8=EC=84=9C=20=EA=B4=80=EB=A6=AC?= =?UTF-8?q?=20=EC=8B=9C=EC=8A=A4=ED=85=9C=20FormRequest=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=20(Phase=201.7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - IndexRequest: 목록 조회 필터/페이징 검증 - StoreRequest: 문서 생성 검증 (템플릿, 데이터, 첨부파일) - UpdateRequest: 문서 수정 검증 Co-Authored-By: Claude --- app/Http/Requests/Document/IndexRequest.php | 37 ++++++++++++ app/Http/Requests/Document/StoreRequest.php | 59 ++++++++++++++++++++ app/Http/Requests/Document/UpdateRequest.php | 55 ++++++++++++++++++ 3 files changed, 151 insertions(+) create mode 100644 app/Http/Requests/Document/IndexRequest.php create mode 100644 app/Http/Requests/Document/StoreRequest.php create mode 100644 app/Http/Requests/Document/UpdateRequest.php diff --git a/app/Http/Requests/Document/IndexRequest.php b/app/Http/Requests/Document/IndexRequest.php new file mode 100644 index 0000000..f31f070 --- /dev/null +++ b/app/Http/Requests/Document/IndexRequest.php @@ -0,0 +1,37 @@ + "nullable|string|in:{$statuses}", + 'template_id' => 'nullable|integer', + 'search' => 'nullable|string|max:100', + 'from_date' => 'nullable|date', + 'to_date' => 'nullable|date|after_or_equal:from_date', + 'sort_by' => 'nullable|string|in:created_at,document_no,title,status,submitted_at,completed_at', + 'sort_dir' => 'nullable|string|in:asc,desc', + 'per_page' => 'nullable|integer|min:1|max:100', + 'page' => 'nullable|integer|min:1', + ]; + } +} diff --git a/app/Http/Requests/Document/StoreRequest.php b/app/Http/Requests/Document/StoreRequest.php new file mode 100644 index 0000000..a6681e1 --- /dev/null +++ b/app/Http/Requests/Document/StoreRequest.php @@ -0,0 +1,59 @@ + 'required|integer|exists:document_templates,id', + 'title' => 'required|string|max:255', + 'linkable_type' => 'nullable|string|max:100', + 'linkable_id' => 'nullable|integer', + + // 결재선 (보류 상태이지만 구조는 유지) + 'approvers' => 'nullable|array', + 'approvers.*.user_id' => 'required_with:approvers|integer|exists:users,id', + 'approvers.*.role' => 'nullable|string|max:50', + + // 문서 데이터 (EAV) + 'data' => 'nullable|array', + 'data.*.section_id' => 'nullable|integer', + 'data.*.column_id' => 'nullable|integer', + 'data.*.row_index' => 'nullable|integer|min:0', + 'data.*.field_key' => 'required_with:data|string|max:100', + 'data.*.field_value' => 'nullable|string', + + // 첨부파일 + 'attachments' => 'nullable|array', + 'attachments.*.file_id' => 'required_with:attachments|integer|exists:files,id', + 'attachments.*.attachment_type' => "nullable|string|in:{$attachmentTypes}", + 'attachments.*.description' => 'nullable|string|max:255', + ]; + } + + public function messages(): array + { + return [ + 'template_id.required' => __('validation.required', ['attribute' => '템플릿']), + 'template_id.exists' => __('validation.exists', ['attribute' => '템플릿']), + 'title.required' => __('validation.required', ['attribute' => '제목']), + 'title.max' => __('validation.max.string', ['attribute' => '제목', 'max' => 255]), + 'approvers.*.user_id.exists' => __('validation.exists', ['attribute' => '결재자']), + 'data.*.field_key.required_with' => __('validation.required', ['attribute' => '필드 키']), + 'attachments.*.file_id.exists' => __('validation.exists', ['attribute' => '파일']), + ]; + } +} diff --git a/app/Http/Requests/Document/UpdateRequest.php b/app/Http/Requests/Document/UpdateRequest.php new file mode 100644 index 0000000..8388c00 --- /dev/null +++ b/app/Http/Requests/Document/UpdateRequest.php @@ -0,0 +1,55 @@ + 'nullable|string|max:255', + 'linkable_type' => 'nullable|string|max:100', + 'linkable_id' => 'nullable|integer', + + // 결재선 (보류 상태이지만 구조는 유지) + 'approvers' => 'nullable|array', + 'approvers.*.user_id' => 'required_with:approvers|integer|exists:users,id', + 'approvers.*.role' => 'nullable|string|max:50', + + // 문서 데이터 (EAV) + 'data' => 'nullable|array', + 'data.*.section_id' => 'nullable|integer', + 'data.*.column_id' => 'nullable|integer', + 'data.*.row_index' => 'nullable|integer|min:0', + 'data.*.field_key' => 'required_with:data|string|max:100', + 'data.*.field_value' => 'nullable|string', + + // 첨부파일 + 'attachments' => 'nullable|array', + 'attachments.*.file_id' => 'required_with:attachments|integer|exists:files,id', + 'attachments.*.attachment_type' => "nullable|string|in:{$attachmentTypes}", + 'attachments.*.description' => 'nullable|string|max:255', + ]; + } + + public function messages(): array + { + return [ + 'title.max' => __('validation.max.string', ['attribute' => '제목', 'max' => 255]), + 'approvers.*.user_id.exists' => __('validation.exists', ['attribute' => '결재자']), + 'data.*.field_key.required_with' => __('validation.required', ['attribute' => '필드 키']), + 'attachments.*.file_id.exists' => __('validation.exists', ['attribute' => '파일']), + ]; + } +}