SubmitBaseInfoRequest.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace App\Http\Requests\Coach;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. class SubmitBaseInfoRequest extends FormRequest
  5. {
  6. public function authorize()
  7. {
  8. return true;
  9. }
  10. public function rules()
  11. {
  12. return [
  13. 'nickname' => 'required|string|min:2|max:20',
  14. 'avatar' => 'required|url|max:255',
  15. 'gender' => 'required|in:1,2',
  16. 'mobile' => ['required', 'string', 'regex:/^1[3-9]\d{9}$/'],
  17. 'birthday' => [
  18. 'required',
  19. 'date',
  20. 'before:'.now()->subYears(18)->format('Y-m-d'),
  21. ],
  22. 'work_years' => 'required|integer|min:0|max:99',
  23. 'intention_city' => 'required|string|max:50',
  24. 'introduction' => 'required|string|min:10|max:255',
  25. ];
  26. }
  27. public function messages()
  28. {
  29. return [
  30. 'nickname.required' => '昵称不能为空',
  31. 'nickname.min' => '昵称不能少于2个字符',
  32. 'nickname.max' => '昵称不能超过20个字符',
  33. 'avatar.required' => '头像不能为空',
  34. 'avatar.url' => '头像必须是有效的URL地址',
  35. 'gender.required' => '性别不能为空',
  36. 'gender.in' => '性别只能是1(男)或2(女)',
  37. 'mobile.required' => '手机号不能为空',
  38. 'mobile.regex' => '手机号格式不正确',
  39. 'birthday.required' => '出生日期不能为空',
  40. 'birthday.date' => '出生日期格式不正确',
  41. 'birthday.before' => '年龄必须满18岁',
  42. 'work_years.required' => '工作年限不能为空',
  43. 'work_years.integer' => '工作年限必须是整数',
  44. 'work_years.min' => '工作年限不能小于0年',
  45. 'work_years.max' => '工作年限不能超过99年',
  46. 'intention_city.required' => '意向城市不能为空',
  47. 'intention_city.max' => '意向城市不能超过50个字符',
  48. 'introduction.required' => '个人简介不能为空',
  49. 'introduction.min' => '个人简介不能少于10个字符',
  50. 'introduction.max' => '个人简介不能超过255个字符',
  51. ];
  52. }
  53. }