GoodsValidate.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace app\admin\validate\life;
  3. use think\Validate;
  4. class GoodsValidate extends Validate
  5. {
  6. protected $rule = [
  7. 'goods_name' => 'require|max:50',
  8. 'goods_id' => 'require',
  9. 'goods_img' => 'require',
  10. 'goods_category_id' => 'require',
  11. 'goods_is_new' => 'require',
  12. 'goods_price' => 'require',
  13. 'goods_content' => 'require',
  14. 'goods_postage_id' => 'require',
  15. 'goods_status' => 'require',
  16. ];
  17. protected $message = [
  18. 'goods_id.require' => '商品ID不能为空',
  19. 'goods_name.require' => '商品名称不能为空',
  20. 'goods_img.require'=> '商品图片不能为空不能为空',
  21. 'goods_category_id.require' => '商品分类id不能为空',
  22. 'goods_name.max' => '商品名称不能超过20字',
  23. 'goods_is_new.require' => '商品上新不能为空',
  24. 'goods_price.require' => '商品价格不能为空',
  25. 'goods_content.require' => '商品详情不能为空',
  26. 'goods_postage_id.require' => '关联运费模板不能为空',
  27. 'goods_status.require' => '商品状态不能为空',
  28. ];
  29. //场景
  30. protected $scene = [
  31. 'create' => ['goods_name','goods_img','goods_category_id','goods_is_new','goods_price','goods_content','goods_postage_id','goods_status'],
  32. 'update' => ['goods_id','goods_name','goods_img','goods_category_id','goods_is_new','goods_price','goods_content','goods_postage_id','goods_status'],
  33. 'info' => ['goods_id']
  34. ];
  35. }