SetLocationRequest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App\Http\Requests\Coach;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. class SetLocationRequest extends FormRequest
  5. {
  6. public function rules()
  7. {
  8. return [
  9. 'latitude' => 'required|numeric|between:-90,90',
  10. 'longitude' => 'required|numeric|between:-180,180',
  11. 'type' => 'nullable|integer|in:1,2',
  12. 'province' => 'nullable|string|max:50',
  13. 'city' => 'nullable|string|max:50',
  14. 'district' => 'nullable|string|max:50',
  15. 'address' => 'nullable|string|max:255',
  16. 'adcode' => 'nullable|string|size:6',
  17. ];
  18. }
  19. public function messages()
  20. {
  21. return [
  22. 'latitude.required' => '纬度不能为空',
  23. 'latitude.numeric' => '纬度必须是数字',
  24. 'latitude.between' => '纬度必须在-90到90之间',
  25. 'longitude.required' => '经度不能为空',
  26. 'longitude.numeric' => '经度必须是数字',
  27. 'longitude.between' => '经度必须在-180到180之间',
  28. 'type.integer' => '位置类型必须是整数',
  29. 'type.in' => '位置类型只能是1(当前位置)或2(常用位置)',
  30. 'province.max' => '省份不能超过50个字符',
  31. 'city.max' => '城市不能超过50个字符',
  32. 'district.max' => '区县不能超过50个字符',
  33. 'address.max' => '详细地址不能超过255个字符',
  34. 'adcode.size' => '行政区划代码必须是6位',
  35. ];
  36. }
  37. }