SubmitRealNameRequest.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace App\Http\Requests\Coach;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. class SubmitRealNameRequest extends FormRequest
  5. {
  6. public function authorize()
  7. {
  8. return true;
  9. }
  10. public function rules()
  11. {
  12. return [
  13. 'real_name' => 'required|string|min:2|max:20',
  14. 'id_card' => [
  15. 'required',
  16. 'string',
  17. 'size:18',
  18. 'regex:/^[1-9]\d{5}(19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dX]$/',
  19. ],
  20. 'id_card_front_photo' => 'required|url|max:255',
  21. 'id_card_back_photo' => 'required|url|max:255',
  22. 'id_card_hand_photo' => 'required|url|max:255',
  23. ];
  24. }
  25. public function messages()
  26. {
  27. return [
  28. 'real_name.required' => '姓名不能为空',
  29. 'real_name.min' => '姓名不能少于2个字符',
  30. 'real_name.max' => '姓名不能超过20个字符',
  31. 'id_card.required' => '身份证号不能为空',
  32. 'id_card.size' => '身份证号必须是18位',
  33. 'id_card.regex' => '身份证号格式不正确',
  34. 'id_card_front_photo.required' => '身份证正面照片不能为空',
  35. 'id_card_front_photo.url' => '身份证正面照片必须是有效的URL地址',
  36. 'id_card_back_photo.required' => '身份证反面照片不能为空',
  37. 'id_card_back_photo.url' => '身份证反面照片必须是有效的URL地址',
  38. 'id_card_hand_photo.required' => '手持身份证照片不能为空',
  39. 'id_card_hand_photo.url' => '手持身份证照片必须是有效的URL地址',
  40. ];
  41. }
  42. }