From 968a4b06c8c02ee1701e412620d586de0eed4118 Mon Sep 17 00:00:00 2001 From: aslan Date: Tue, 13 Feb 2024 15:38:30 +0300 Subject: [PATCH] refactoring requests rules --- app/Http/Requests/StoreFileRequest.php | 31 ------------------- app/Http/Requests/UpdateFileRequest.php | 30 ------------------ .../admin/Catalog/StoreDepartmentRequest.php | 2 +- .../admin/Catalog/StoreDirectionRequest.php | 2 +- .../StoreEducationalInstitutionRequest.php | 2 +- .../admin/Catalog/StoreFacultyRequest.php | 6 ++-- .../admin/Catalog/UpdateDepartmentRequest.php | 2 +- .../admin/Catalog/UpdateDirectionRequest.php | 4 +-- .../UpdateEducationalInstitutionRequest.php | 2 +- .../admin/Catalog/UpdateFacultyRequest.php | 4 +-- .../Requests/{ => admin}/StoreUserRequest.php | 2 +- .../{ => admin}/UpdateUserRequest.php | 2 +- 12 files changed, 14 insertions(+), 75 deletions(-) delete mode 100644 app/Http/Requests/StoreFileRequest.php delete mode 100644 app/Http/Requests/UpdateFileRequest.php rename app/Http/Requests/{ => admin}/StoreUserRequest.php (94%) rename app/Http/Requests/{ => admin}/UpdateUserRequest.php (94%) diff --git a/app/Http/Requests/StoreFileRequest.php b/app/Http/Requests/StoreFileRequest.php deleted file mode 100644 index 16494be..0000000 --- a/app/Http/Requests/StoreFileRequest.php +++ /dev/null @@ -1,31 +0,0 @@ -|string> - */ - public function rules(): array - { - return [ - 'name' => 'max:255', - 'position' => 'int|max:255', - 'url' => 'file', - 'idReceptionScreen' => 'int|max:255', - ]; - } -} diff --git a/app/Http/Requests/UpdateFileRequest.php b/app/Http/Requests/UpdateFileRequest.php deleted file mode 100644 index a9854c0..0000000 --- a/app/Http/Requests/UpdateFileRequest.php +++ /dev/null @@ -1,30 +0,0 @@ -|string> - */ - public function rules(): array - { - return [ - 'name' => 'required|max:255', - 'position' => 'required||int|max:255', - 'idReceptionScreen' => 'int|max:255', - ]; - } -} diff --git a/app/Http/Requests/admin/Catalog/StoreDepartmentRequest.php b/app/Http/Requests/admin/Catalog/StoreDepartmentRequest.php index f334a8a..df07a9d 100644 --- a/app/Http/Requests/admin/Catalog/StoreDepartmentRequest.php +++ b/app/Http/Requests/admin/Catalog/StoreDepartmentRequest.php @@ -16,7 +16,7 @@ class StoreDepartmentRequest extends FormRequest { return [ 'position' => 'required|int|max:255', - 'name' => 'required|string|max:255|unique:educational_institutions,name', + 'name' => 'required|string|max:255|unique:departments,name', 'description' => 'string', 'slug' => 'required|string', 'faculty_id' => 'required|int', diff --git a/app/Http/Requests/admin/Catalog/StoreDirectionRequest.php b/app/Http/Requests/admin/Catalog/StoreDirectionRequest.php index 16e0f91..88abe17 100644 --- a/app/Http/Requests/admin/Catalog/StoreDirectionRequest.php +++ b/app/Http/Requests/admin/Catalog/StoreDirectionRequest.php @@ -15,7 +15,7 @@ class StoreDirectionRequest extends FormRequest { return [ 'position' => 'required|int|max:255', - 'name' => 'required|string|max:255|unique:educational_institutions,name', + 'name' => 'required|string|max:255|unique:directions,name', 'description' => 'string', 'slug' => 'required|string', 'department_id' => 'required|int' diff --git a/app/Http/Requests/admin/Catalog/StoreEducationalInstitutionRequest.php b/app/Http/Requests/admin/Catalog/StoreEducationalInstitutionRequest.php index 4ac4373..255fd9f 100644 --- a/app/Http/Requests/admin/Catalog/StoreEducationalInstitutionRequest.php +++ b/app/Http/Requests/admin/Catalog/StoreEducationalInstitutionRequest.php @@ -14,7 +14,7 @@ class StoreEducationalInstitutionRequest extends FormRequest public function rules(): array { return [ - 'position' => 'int|max:255', + 'position' => 'required|int|max:255', 'name' => 'required|string|max:255|unique:educational_institutions,name', 'description' => 'string', 'slug' => 'required|string', diff --git a/app/Http/Requests/admin/Catalog/StoreFacultyRequest.php b/app/Http/Requests/admin/Catalog/StoreFacultyRequest.php index 55f5986..1e5b86b 100644 --- a/app/Http/Requests/admin/Catalog/StoreFacultyRequest.php +++ b/app/Http/Requests/admin/Catalog/StoreFacultyRequest.php @@ -15,11 +15,11 @@ class StoreFacultyRequest extends FormRequest public function rules(): array { return [ - 'position' => 'int|max:255', - 'name' => 'required|string|max:255|unique:educational_institutions,name', + 'position' => 'required|int|max:255', + 'name' => 'required|string|max:255|unique:faculties,name', 'description' => 'string', 'slug' => 'required|string', - 'educational_institution_id' => 'int' + 'educational_institution_id' => 'required|int' ]; } } diff --git a/app/Http/Requests/admin/Catalog/UpdateDepartmentRequest.php b/app/Http/Requests/admin/Catalog/UpdateDepartmentRequest.php index 5f1e5a1..b755a76 100644 --- a/app/Http/Requests/admin/Catalog/UpdateDepartmentRequest.php +++ b/app/Http/Requests/admin/Catalog/UpdateDepartmentRequest.php @@ -21,7 +21,7 @@ class UpdateDepartmentRequest extends FormRequest 'required', 'string', 'max:255', - "unique:educational_institutions,name,{$this->department->id}", + "unique:departments,name,{$this->department->id}", ], ]; } diff --git a/app/Http/Requests/admin/Catalog/UpdateDirectionRequest.php b/app/Http/Requests/admin/Catalog/UpdateDirectionRequest.php index f5db324..97b190d 100644 --- a/app/Http/Requests/admin/Catalog/UpdateDirectionRequest.php +++ b/app/Http/Requests/admin/Catalog/UpdateDirectionRequest.php @@ -15,7 +15,7 @@ class UpdateDirectionRequest extends FormRequest public function rules(): array { return [ - 'position' => 'int|max:255', + 'position' => 'required|int|max:255', 'description' => 'string', 'department_id' => 'int|required', 'slug' => 'required|string', @@ -23,7 +23,7 @@ class UpdateDirectionRequest extends FormRequest 'required', 'string', 'max:255', - "unique:educational_institutions,name,{$this->direction->id}", + "unique:directions,name,{$this->direction->id}", ], ]; } diff --git a/app/Http/Requests/admin/Catalog/UpdateEducationalInstitutionRequest.php b/app/Http/Requests/admin/Catalog/UpdateEducationalInstitutionRequest.php index ac81bde..ed34b64 100644 --- a/app/Http/Requests/admin/Catalog/UpdateEducationalInstitutionRequest.php +++ b/app/Http/Requests/admin/Catalog/UpdateEducationalInstitutionRequest.php @@ -15,7 +15,7 @@ class UpdateEducationalInstitutionRequest extends FormRequest public function rules(): array { return [ - 'position' => 'int|max:255', + 'position' => 'required|int|max:255', 'description' => 'string', 'slug' => 'required|string', 'name' => [ diff --git a/app/Http/Requests/admin/Catalog/UpdateFacultyRequest.php b/app/Http/Requests/admin/Catalog/UpdateFacultyRequest.php index bb25df7..e5ab5b3 100644 --- a/app/Http/Requests/admin/Catalog/UpdateFacultyRequest.php +++ b/app/Http/Requests/admin/Catalog/UpdateFacultyRequest.php @@ -14,10 +14,10 @@ class UpdateFacultyRequest extends FormRequest public function rules(): array { return [ - 'position' => 'int|max:255', + 'position' => 'required|int|max:255', 'description' => 'string', 'slug' => 'required|string', - 'educational_institution_id' => 'int', + 'educational_institution_id' => 'required|int', 'name' => [ 'required', 'string', diff --git a/app/Http/Requests/StoreUserRequest.php b/app/Http/Requests/admin/StoreUserRequest.php similarity index 94% rename from app/Http/Requests/StoreUserRequest.php rename to app/Http/Requests/admin/StoreUserRequest.php index ec4535d..6d8e995 100644 --- a/app/Http/Requests/StoreUserRequest.php +++ b/app/Http/Requests/admin/StoreUserRequest.php @@ -1,6 +1,6 @@