截流自动化的商城平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UserAddressValidate.php 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace app\api\validate;
  3. use app\common\basics\Validate;
  4. class UserAddressValidate extends Validate
  5. {
  6. protected $rule = [
  7. 'id' => 'require|integer',
  8. 'contact' => 'require',
  9. 'telephone' => [ 'require', 'checkMobile' => [ 'check' => [ 'land', 'hk' ] ] ],
  10. 'province_id' => 'require',
  11. 'city_id' => 'require',
  12. 'district_id' => 'require',
  13. 'address' => 'require',
  14. 'is_default' => 'require',
  15. ];
  16. protected $message = [
  17. 'id.require' => 'id不能为空',
  18. 'id.integer' => 'id参数错误',
  19. 'contact.require' => '收货人不能为空',
  20. 'telephone.require' => '联系方式不能为空',
  21. 'telephone.mobile' => '非有效手机号',
  22. 'province_id.require' => '所选地区不能为空',
  23. 'city_id.require' => '请选择完整地址',
  24. 'district_id.require' => '请选择完整地址',
  25. 'address.require' => '详细地址不能为空',
  26. 'is_default.require' => '是否默认不能为空',
  27. 'province.require' => '省不能为空',
  28. 'city.require' => '市不能为空',
  29. 'district.require' => '区不能为空',
  30. ];
  31. protected $scene = [
  32. 'add' => ['contact','telephone','province_id','city_id','district_id','is_default','address'],
  33. 'set'=>['id'],
  34. 'one'=>['id'],
  35. 'edit'=>['id','contact','telephone','province_id','city_id','district_id','is_default'],
  36. 'del'=>['id'],
  37. ];
  38. /**
  39. * 获取省市区id
  40. */
  41. public function sceneHandleRegion()
  42. {
  43. return $this->only(['province','city','district'])
  44. ->append('province','require')
  45. ->append('city','require')
  46. ->append('district','require');
  47. }
  48. }