BasicInfoRequest.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace App\Http\Requests\Coach\Auth;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. class BasicInfoRequest extends FormRequest
  5. {
  6. public function authorize(): bool
  7. {
  8. return true;
  9. }
  10. public function rules(): array
  11. {
  12. return [
  13. 'nickname' => 'required|string|max:255',
  14. 'avatar' => 'nullable|string|max:255',
  15. 'gender' => 'required|integer|in:1,2',
  16. 'mobile' => 'required|string|regex:/^1[3-9]\d{9}$/',
  17. 'age' => 'required|integer|min:18|max:60',
  18. 'birthday' => 'nullable|date',
  19. 'work_years' => 'nullable|integer|min:0|max:50',
  20. 'intention_city' => 'required|string|max:255',
  21. 'introduction' => 'nullable|string|max:1000',
  22. 'portrait_images' => 'required|array|min:1|max:6',
  23. 'portrait_images.*' => 'required|string|max:255'
  24. ];
  25. }
  26. public function messages(): array
  27. {
  28. return [
  29. 'nickname.required' => '昵称不能为空',
  30. 'nickname.max' => '昵称不能超过255个字符',
  31. 'avatar.max' => '头像地址不能超过255个字符',
  32. 'gender.required' => '性别不能为空',
  33. 'gender.integer' => '性别必须是整数',
  34. 'gender.in' => '性别只能是1(男)或2(女)',
  35. 'mobile.required' => '手机号不能为空',
  36. 'mobile.regex' => '手机号格式不正确',
  37. 'age.required' => '年龄不能为空',
  38. 'age.integer' => '年龄必须是整数',
  39. 'age.min' => '年龄不能小于18岁',
  40. 'age.max' => '年龄不能大于60岁',
  41. 'birthday.date' => '出生日期格式不正确',
  42. 'work_years.integer' => '工作年限必须是整数',
  43. 'work_years.min' => '工作年限不能小于0年',
  44. 'work_years.max' => '工作年限不能超过50年',
  45. 'intention_city.required' => '意向城市不能为空',
  46. 'intention_city.max' => '意向城市不能超过255个字符',
  47. 'introduction.max' => '个人简介不能超过1000个字符',
  48. 'portrait_images.required' => '形象照片不能为空',
  49. 'portrait_images.array' => '形象照片必须是数组',
  50. 'portrait_images.min' => '至少上传1张形象照片',
  51. 'portrait_images.max' => '最多上传6张形象照片',
  52. 'portrait_images.*.required' => '形象照片不能为空',
  53. 'portrait_images.*.string' => '形象照片必须是字符串',
  54. 'portrait_images.*.max' => '形象照片地���不能超过255个字符'
  55. ];
  56. }
  57. }