StoreCouponValidate.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\validate\admin\marketing;
  12. use think\Validate;
  13. class StoreCouponValidate extends Validate
  14. {
  15. /**
  16. * 定义验证规则
  17. * 格式:'字段名' => ['规则1','规则2'...]
  18. *
  19. * @var array
  20. */
  21. protected $rule = [
  22. 'title' => 'require',
  23. 'image' => 'require',
  24. 'category_id' => 'require',
  25. 'coupon_price' => 'require',
  26. 'use_min_price' => 'require',
  27. 'coupon_time' => 'require',
  28. 'status' => 'In:0,1',
  29. 'type' => ['require', 'In:0,1,2'],
  30. ];
  31. /**
  32. * 定义错误信息
  33. * 格式:'字段名.规则名' => '错误信息'
  34. *
  35. * @var array
  36. */
  37. protected $message = [
  38. 'title.require' => '请填写优惠卷名称',
  39. 'image.require' => '请选择商品',
  40. 'category_id.require' => '请选择商品类型',
  41. 'coupon_price.require' => '请填写优惠卷金额',
  42. 'use_min_price.require' => '请填写优惠卷最小使用金额',
  43. 'coupon_time.require' => '请填写优惠卷有效期',
  44. ];
  45. protected $scene = [
  46. 'save' => ['title', 'coupon_price', 'use_min_price', 'coupon_time'],
  47. 'type' => ['title', 'category_id', 'coupon_price', 'use_min_price', 'coupon_time'],
  48. 'product' => ['title', 'image', 'coupon_price', 'use_min_price', 'coupon_time'],
  49. ];
  50. }