ApplyCoachRequest.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace App\Http\Requests\Client\User;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. class ApplyCoachRequest extends FormRequest
  5. {
  6. public function authorize(): bool
  7. {
  8. return true;
  9. }
  10. public function rules(): array
  11. {
  12. return [
  13. 'age' => [
  14. 'required',
  15. 'integer',
  16. 'min:18',
  17. 'max:60',
  18. ],
  19. 'mobile' => [
  20. 'required',
  21. 'string',
  22. 'regex:/^1[3-9]\d{9}$/',
  23. ],
  24. 'gender' => [
  25. 'required',
  26. 'integer',
  27. 'in:1,2',
  28. ],
  29. 'work_years' => [
  30. 'required',
  31. 'integer',
  32. 'min:0',
  33. 'max:50',
  34. ],
  35. 'intention_city' => [
  36. 'required',
  37. 'string',
  38. 'max:50',
  39. ],
  40. 'portrait_images' => [
  41. 'required',
  42. 'array',
  43. 'min:1',
  44. 'max:6',
  45. ],
  46. 'introduction' => [
  47. 'nullable',
  48. 'string',
  49. 'max:1000',
  50. ],
  51. ];
  52. }
  53. public function messages(): array
  54. {
  55. return [
  56. 'age.required' => '年龄不能为空',
  57. 'age.integer' => '年龄必须是整数',
  58. 'age.min' => '年龄不能小于18岁',
  59. 'age.max' => '年龄不能大于60岁',
  60. 'mobile.required' => '手机号不能为空',
  61. 'mobile.regex' => '手机号格式不正确',
  62. 'gender.required' => '性别不能为空',
  63. 'gender.in' => '性别只能是1(男)或2(女)',
  64. 'work_years.required' => '工作年限不能为空',
  65. 'work_years.integer' => '工作年限必须是整数',
  66. 'work_years.min' => '工作年限不能小于0年',
  67. 'work_years.max' => '工作年限不能超过50年',
  68. 'intention_city.required' => '意向城市不能为空',
  69. 'intention_city.max' => '意向城市不能超过50个字符',
  70. 'portrait_images.required' => '形象照片不能为空',
  71. 'portrait_images.array' => '形象照片必须是数组',
  72. 'portrait_images.min' => '至少上传1张形象照片',
  73. 'portrait_images.max' => '最多上传6张形象照片',
  74. 'introduction.max' => '个人简介不能超过1000个字符',
  75. ];
  76. }
  77. }