SubmitBaseInfoRequest.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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' => 'nullable|string|min:2|max:20',
  14. 'avatar' => 'nullable|string|max:2048',
  15. 'life_photos' => 'nullable|array',
  16. 'life_photos.*' => 'required|string|max:2048',
  17. 'gender' => 'required|string|in:1,2',
  18. 'mobile' => 'required|string|size:11',
  19. 'birthday' => 'nullable|date|before:' . now()->subYears(18)->format('Y-m-d'),
  20. 'work_years' => 'nullable|integer|min:0|max:99',
  21. 'intention_city' => 'nullable|string|max:50',
  22. 'introduction' => 'nullable|string|min:10|max:255',
  23. ];
  24. }
  25. public function messages()
  26. {
  27. return [
  28. 'nickname.string' => '昵称必须是字符串',
  29. 'nickname.min' => '昵称不能少于2个字符',
  30. 'nickname.max' => '昵称不能超过20个字符',
  31. 'avatar.string' => '头像必须是有效的字符串',
  32. 'avatar.max' => '头像大小不能超过2048字节',
  33. 'gender.required' => '性别不能为空',
  34. 'gender.in' => '性别只能是1(男)或2(女)',
  35. 'mobile.required' => '手机号不能为空',
  36. 'mobile.string' => '手机号必须是有效的字符串',
  37. 'mobile.size' => '手机号长度必须是11位',
  38. 'birthday.date' => '出生日期格式不正确',
  39. 'birthday.before' => '年龄必须满18岁',
  40. 'work_years.integer' => '工作年限必须是整数',
  41. 'work_years.min' => '工作年限不能小于0年',
  42. 'work_years.max' => '工作年限不能超过99年',
  43. 'intention_city.max' => '意向城市不能超过50个字符',
  44. 'introduction.min' => '个人简介不能少于10个字符',
  45. 'introduction.max' => '个人简介不能超过255个字符',
  46. 'life_photos.array' => '生活照片必须是数组格式',
  47. 'life_photos.*.required' => '生活照片不能为空',
  48. 'life_photos.*.string' => '生活照片格式不正确',
  49. 'life_photos.*.max' => '生活照片数据过大',
  50. ];
  51. }
  52. }