refactoring fix unique field slug in Requests

This commit is contained in:
aslan 2024-02-15 14:46:35 +03:00
parent 9beeeb4edb
commit 23033cbb1f
12 changed files with 32 additions and 12 deletions

View File

@ -18,7 +18,7 @@ class StoreDepartmentRequest extends FormRequest
'position' => 'required|int|numeric|max:255', 'position' => 'required|int|numeric|max:255',
'name' => 'required|string|max:255|unique:departments,name', 'name' => 'required|string|max:255|unique:departments,name',
'description' => 'string', 'description' => 'string',
'slug' => 'required|string|max:255', 'slug' => 'required|string|max:255|unique:departments,slug',
'faculty_id' => 'required|numeric|int|max:1000', 'faculty_id' => 'required|numeric|int|max:1000',
]; ];
} }

View File

@ -17,7 +17,7 @@ class StoreDirectionRequest extends FormRequest
'position' => 'required|int|numeric|max:255', 'position' => 'required|int|numeric|max:255',
'name' => 'required|string|max:255|unique:directions,name', 'name' => 'required|string|max:255|unique:directions,name',
'description' => 'string', 'description' => 'string',
'slug' => 'required|string|max:255', 'slug' => 'required|string|max:255|unique:directions,slug',
'code' => 'required|string|max:255', 'code' => 'required|string|max:255',
'education_level_id' => 'required|int|numeric|max:1000', 'education_level_id' => 'required|int|numeric|max:1000',
'education_form_id' => 'required|int|numeric|max:1000', 'education_form_id' => 'required|int|numeric|max:1000',

View File

@ -16,7 +16,7 @@ class StoreEducationFormRequest extends FormRequest
return [ return [
'name' => 'required|string|max:255|unique:education_levels,name', 'name' => 'required|string|max:255|unique:education_levels,name',
'description' => 'string', 'description' => 'string',
'slug' => 'required|string|max:255', 'slug' => 'required|string|max:255|unique:education_levels,slug',
]; ];
} }
} }

View File

@ -16,7 +16,7 @@ class StoreEducationLevelRequest extends FormRequest
return [ return [
'name' => 'required|string|max:255|unique:education_levels,name', 'name' => 'required|string|max:255|unique:education_levels,name',
'description' => 'string', 'description' => 'string',
'slug' => 'required|string|max:255', 'slug' => 'required|string|max:255|unique:education_levels,slug',
]; ];
} }
} }

View File

@ -17,7 +17,7 @@ class StoreEducationalInstitutionRequest extends FormRequest
'position' => 'required|int|numeric|max:255', 'position' => 'required|int|numeric|max:255',
'name' => 'required|string|max:255|unique:educational_institutions,name', 'name' => 'required|string|max:255|unique:educational_institutions,name',
'description' => 'string', 'description' => 'string',
'slug' => 'required|string|max:255', 'slug' => 'required|string|max:255|unique:educational_institutions,slug',
]; ];
} }
} }

View File

@ -18,7 +18,7 @@ class StoreFacultyRequest extends FormRequest
'position' => 'required|int|numeric|max:255', 'position' => 'required|int|numeric|max:255',
'name' => 'required|string|max:255|unique:faculties,name', 'name' => 'required|string|max:255|unique:faculties,name',
'description' => 'string', 'description' => 'string',
'slug' => 'required|string|max:255', 'slug' => 'required|string|max:255|unique:faculties,slug',
'educational_institution_id' => 'required|int|numeric|max:1000' 'educational_institution_id' => 'required|int|numeric|max:1000'
]; ];
} }

View File

@ -15,7 +15,12 @@ class UpdateDepartmentRequest extends FormRequest
return [ return [
'position' => 'required|int|numeric|max:255', 'position' => 'required|int|numeric|max:255',
'description' => 'string', 'description' => 'string',
'slug' => 'string|required|max:255', 'slug' => [
'string',
'required',
'max:255',
"unique:departments,slug,{$this->department->id}",
],
'faculty_id' => 'int|required|numeric|max:255', 'faculty_id' => 'int|required|numeric|max:255',
'name' => [ 'name' => [
'required', 'required',

View File

@ -18,7 +18,12 @@ class UpdateDirectionRequest extends FormRequest
'position' => 'required||numeric|int|max:255', 'position' => 'required||numeric|int|max:255',
'description' => 'string', 'description' => 'string',
'department_id' => 'int|required|numeric|max:1000', 'department_id' => 'int|required|numeric|max:1000',
'slug' => 'required|string|max:255', 'slug' => [
'required',
'string',
'max:255',
"unique:directions,slug,{$this->direction->id}",
],
'code' => 'required|string|max:255', 'code' => 'required|string|max:255',
'education_level_id' => 'required|int|numeric|max:1000', 'education_level_id' => 'required|int|numeric|max:1000',
'education_form_id' => 'required|int|numeric|max:1000', 'education_form_id' => 'required|int|numeric|max:1000',

View File

@ -16,7 +16,7 @@ class UpdateEducationFormRequest extends FormRequest
return [ return [
'name' => "required|string|max:255|unique:education_forms,name,{$this->education_form->id}", 'name' => "required|string|max:255|unique:education_forms,name,{$this->education_form->id}",
'description' => 'string', 'description' => 'string',
'slug' => 'required|string|max:255', 'slug' => "required|string|max:255|unique:education_forms,slug,{$this->education_form->id}",
]; ];
} }
} }

View File

@ -16,7 +16,7 @@ class UpdateEducationLevelRequest extends FormRequest
return [ return [
'name' => "required|string|max:255|unique:education_levels,name,{$this->education_level->id}", 'name' => "required|string|max:255|unique:education_levels,name,{$this->education_level->id}",
'description' => 'string', 'description' => 'string',
'slug' => 'required|string|max:255', 'slug' => "required|string|max:255|unique:education_levels,slug,{$this->education_level->id}",
]; ];
} }
} }

View File

@ -17,7 +17,12 @@ class UpdateEducationalInstitutionRequest extends FormRequest
return [ return [
'position' => 'required|int|numeric|max:255', 'position' => 'required|int|numeric|max:255',
'description' => 'string', 'description' => 'string',
'slug' => 'required|string|max:255', 'slug' => [
'required',
'string',
'max:255',
"unique:educational_institutions,slug,{$this->educational_institution->id}",
],
'name' => [ 'name' => [
'required', 'required',
'string', 'string',

View File

@ -16,7 +16,12 @@ class UpdateFacultyRequest extends FormRequest
return [ return [
'position' => 'required|int|numeric|max:255', 'position' => 'required|int|numeric|max:255',
'description' => 'string', 'description' => 'string',
'slug' => 'required|string|max:255', 'slug' => [
'required',
'string',
'max:255',
"unique:faculties,slug,{$this->faculty->id}",
],
'educational_institution_id' => 'required|int|numeric|max:255', 'educational_institution_id' => 'required|int|numeric|max:255',
'name' => [ 'name' => [
'required', 'required',