Memberaddress.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace app\common\validate;
  3. use think\Validate;/**
  4. * ============================================================================
  5. *
  6. * ============================================================================
  7. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  8. * 网站地址: https://www.valimart.net/
  9. * ----------------------------------------------------------------------------
  10. *
  11. * ============================================================================
  12. * 验证器
  13. */
  14. class Memberaddress extends Validate
  15. {
  16. protected $rule = [
  17. 'city_id'=>'gt:0',
  18. 'area_id'=>'gt:0',
  19. 'address_realname'=>'require',
  20. 'area_info'=>'require',
  21. 'address_detail'=>'require',
  22. 'address_mob_phone'=>'checkMemberAddressMobPhone:1'//
  23. ];
  24. protected $message = [
  25. 'city_id.gt'=>'请选择地区',
  26. 'area_id.gt'=>'地区至少两级',
  27. 'address_realname.require'=>'姓名不能为空',
  28. 'area_info.require'=>'地区不能为空',
  29. 'address_detail.require'=>'地址不能为空',
  30. 'address_mob_phone.checkMemberAddressMobPhone'=>'联系方式不能为空'//
  31. ];
  32. protected $scene = [
  33. 'add' => ['address_realname', 'city_id', 'area_id'],
  34. 'edit' => ['address_realname', 'city_id', 'area_id'],
  35. 'address_valid' => ['address_realname', 'area_info', 'address_detail', 'address_mob_phone'],//mobile
  36. ];
  37. protected function checkMemberAddressMobPhone($value)
  38. {
  39. if (empty(input('post.mob_phone'))&&empty(input('post.tel_phone'))){
  40. if (empty($value)) {
  41. return '联系方式不能为空';
  42. }
  43. }
  44. return true;
  45. }
  46. }