ApplyCoachRequest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. 'mobile' => 'required|string|size:11|regex:/^1[3-9]\d{9}$/',
  14. 'gender' => 'required|integer|in:1,2',
  15. 'work_years' => 'required|integer|min:0|max:50',
  16. 'intention_city' => 'required|string|max:50',
  17. 'portrait_images' => 'required|array',
  18. 'portrait_images.*' => 'required|string|url|max:255',
  19. 'description' => 'nullable|string|max:1000',
  20. ];
  21. }
  22. public function messages(): array
  23. {
  24. return [
  25. 'mobile.required' => '手机号不能为空',
  26. 'mobile.regex' => '手机号格式不正确',
  27. 'gender.required' => '性别不能为空',
  28. 'gender.integer' => '性别必须是整数',
  29. 'gender.in' => '性别只能是1(男)或2(女)',
  30. 'work_years.required' => '工作年限不能为空',
  31. 'work_years.integer' => '工作年限必须是整数',
  32. 'work_years.min' => '工作年限不能小于0年',
  33. 'work_years.max' => '工作年限不能超过50年',
  34. 'intention_city.required' => '意向城市不能为空',
  35. 'portrait_images.required' => '形象图片不能为空',
  36. 'portrait_images.*.url' => '图片必须是有效的URL地址',
  37. ];
  38. }
  39. }