refactoring Requests max characters and numeric field

This commit is contained in:
aslan 2024-02-14 16:41:19 +03:00
parent 6954e296d6
commit e7818471db
16 changed files with 41 additions and 51 deletions

View File

@ -15,11 +15,11 @@ class StoreDepartmentRequest extends FormRequest
public function rules(): array public function rules(): array
{ {
return [ return [
'position' => 'required|int|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', 'slug' => 'required|string|max:255',
'faculty_id' => 'required|int', 'faculty_id' => 'required|numeric|int|max:1000',
]; ];
} }
} }

View File

@ -14,13 +14,13 @@ class StoreDirectionRequest extends FormRequest
public function rules(): array public function rules(): array
{ {
return [ return [
'position' => 'required|int|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', 'slug' => 'required|string|max:255',
'code' => 'required|string', 'code' => 'required|string|max:255',
'education_level_id' => 'required|int', 'education_level_id' => 'required|int|numeric|max:1000',
'department_id' => 'required|int' 'department_id' => 'required|numeric|int|max:1000'
]; ];
} }
} }

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', 'slug' => 'required|string|max:255',
]; ];
} }
} }

View File

@ -14,10 +14,10 @@ class StoreEducationalInstitutionRequest extends FormRequest
public function rules(): array public function rules(): array
{ {
return [ return [
'position' => 'required|int|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', 'slug' => 'required|string|max:255',
]; ];
} }
} }

View File

@ -15,11 +15,11 @@ class StoreFacultyRequest extends FormRequest
public function rules(): array public function rules(): array
{ {
return [ return [
'position' => 'required|int|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', 'slug' => 'required|string|max:255',
'educational_institution_id' => 'required|int' 'educational_institution_id' => 'required|int|numeric|max:1000'
]; ];
} }
} }

View File

@ -13,10 +13,10 @@ class UpdateDepartmentRequest extends FormRequest
public function rules(): array public function rules(): array
{ {
return [ return [
'position' => 'required|int|max:255', 'position' => 'required|int|numeric|max:255',
'description' => 'string', 'description' => 'string',
'slug' => 'string|required', 'slug' => 'string|required|max:255',
'faculty_id' => 'int|required', 'faculty_id' => 'int|required|numeric|max:255',
'name' => [ 'name' => [
'required', 'required',
'string', 'string',

View File

@ -15,12 +15,12 @@ class UpdateDirectionRequest extends FormRequest
public function rules(): array public function rules(): array
{ {
return [ return [
'position' => 'required|int|max:255', 'position' => 'required||numeric|int|max:255',
'description' => 'string', 'description' => 'string',
'department_id' => 'int|required', 'department_id' => 'int|required|numeric|max:1000',
'slug' => 'required|string', 'slug' => 'required|string|max:255',
'code' => 'required|string', 'code' => 'required|string|max:255',
'education_level_id' => 'required|int', 'education_level_id' => 'required|int|numeric|max:1000',
'name' => [ 'name' => [
'required', 'required',
'string', 'string',

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', 'slug' => 'required|string|max:255',
]; ];
} }
} }

View File

@ -15,9 +15,9 @@ class UpdateEducationalInstitutionRequest extends FormRequest
public function rules(): array public function rules(): array
{ {
return [ return [
'position' => 'required|int|max:255', 'position' => 'required|int|numeric|max:255',
'description' => 'string', 'description' => 'string',
'slug' => 'required|string', 'slug' => 'required|string|max:255',
'name' => [ 'name' => [
'required', 'required',
'string', 'string',

View File

@ -14,10 +14,10 @@ class UpdateFacultyRequest extends FormRequest
public function rules(): array public function rules(): array
{ {
return [ return [
'position' => 'required|int|max:255', 'position' => 'required|int|numeric|max:255',
'description' => 'string', 'description' => 'string',
'slug' => 'required|string', 'slug' => 'required|string|max:255',
'educational_institution_id' => 'required|int', 'educational_institution_id' => 'required|int|numeric|max:255',
'name' => [ 'name' => [
'required', 'required',
'string', 'string',

View File

@ -14,10 +14,10 @@ class StoreAdmissionRequest extends FormRequest
public function rules(): array public function rules(): array
{ {
return [ return [
'position' => 'required|int|max:255', 'position' => 'required|int|numeric|max:255',
'name' => 'required|string|max:255|unique:admissions,name', 'name' => 'required|string|max:255|unique:admissions,name',
'description' => 'string', 'description' => 'string',
'slug' => 'required|string', 'slug' => 'required|string|max:255',
]; ];
} }
} }

View File

@ -15,11 +15,11 @@ class StoreDocumentRequest extends FormRequest
public function rules(): array public function rules(): array
{ {
return [ return [
'name' => 'required|max:255', 'name' => 'required|string|max:255',
'description' => 'string', 'description' => 'string',
'position' => 'required|int|max:255', 'position' => 'required|int|numeric|max:255',
'document' => 'required|file', 'document' => 'required|file',
'admission_id' => 'required|int|max:255', 'admission_id' => 'required|int|numeric|max:1000',
]; ];
} }
} }

View File

@ -6,26 +6,16 @@ use Illuminate\Foundation\Http\FormRequest;
class StoreUserRequest extends FormRequest class StoreUserRequest extends FormRequest
{ {
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() public function authorize()
{ {
return true; return true;
} }
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules() public function rules()
{ {
return [ return [
'name' => 'required|unique:users,name|max:255', 'name' => 'required|unique:users,name|max:255',
'email' => 'email', 'email' => 'email|string|max:255',
'password' => 'required' 'password' => 'required'
]; ];
} }

View File

@ -14,9 +14,9 @@ class UpdateAdmissionRequest extends FormRequest
public function rules(): array public function rules(): array
{ {
return [ return [
'position' => 'required|int|max:255', 'position' => 'required|int|numeric|max:255',
'description' => 'string', 'description' => 'string',
'slug' => 'string|required', 'slug' => 'string|required|max:255',
'name' => [ 'name' => [
'required', 'required',
'string', 'string',

View File

@ -20,9 +20,9 @@ class UpdateDocumentRequest extends FormRequest
'max:255', 'max:255',
"unique:documents,name,{$this->document->id}", "unique:documents,name,{$this->document->id}",
], ],
'position' => 'required|int|max:255', 'position' => 'required|int|numeric|max:255',
'description' => 'string', 'description' => 'string',
'admission_id' => 'required|int|max:255', 'admission_id' => 'required|int|numeric|max:1000',
]; ];
} }
} }

View File

@ -24,9 +24,9 @@ class UpdateUserRequest extends FormRequest
public function rules() public function rules()
{ {
return [ return [
'name' => 'required|max:255', 'name' => 'required|string|max:255',
'email' => 'email', 'email' => 'email|string|max:255',
'password' => 'required' 'password' => 'required|max:255'
]; ];
} }
} }