Goods.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace app\common\validate;
  3. use think\Validate;
  4. /**
  5. * ============================================================================
  6. *
  7. * ============================================================================
  8. *
  9. * ----------------------------------------------------------------------------
  10. *
  11. * ============================================================================
  12. * 验证器
  13. */
  14. class Goods extends Validate
  15. {
  16. protected $rule = [
  17. 'goods_name' => 'require|max:200',
  18. 'goods_price' => 'require',
  19. 'gc_name' => 'require',
  20. 'gc_sort' => 'between:0,255',
  21. 'goods_content' => 'require',
  22. ];
  23. protected $message = [
  24. 'goods_name.require' => '商品名称不能为空',
  25. 'goods_name.max' => '商品名称不能超过200个字符',
  26. 'goods_price.require' => '商品价格不能为空',
  27. 'gc_name.require' => '分类标题为必填',
  28. 'gc_sort.between' => '排序应该在0至255之间',
  29. 'goods_content.require' => '咨询内容不能为空',
  30. ];
  31. protected $scene = [
  32. 'edit_save_goods' => ['goods_name', 'goods_price'],
  33. 'goods_class_add' => ['gc_name', 'gc_sort'], //goodsclass
  34. 'goods_class_edit' => ['gc_name', 'gc_sort'], //goodsclass
  35. 'save_consult' => ['goods_content'], //home goods
  36. ];
  37. }