FarmGoodsValidate.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace app\admin\validate\life;
  3. use think\Validate;
  4. class FarmGoodsValidate extends Validate
  5. {
  6. protected $rule = [
  7. 'goods_name' => 'require|max:100',
  8. 'goods_img' => 'require',
  9. 'food_silde' => 'require',
  10. 'goods_category_id' => 'require',
  11. 'goods_shop_id' => 'require',
  12. 'goods_is_new' => 'require',
  13. 'goods_price' => 'require',
  14. 'goods_content' => 'require',
  15. 'goods_sell_num' => 'require',
  16. 'goods_postage_id' => 'require',
  17. 'goods_status' => 'require',
  18. 'goods_weight' => 'require',
  19. 'food_storage' => 'require',
  20. 'food_packaging' => 'require',
  21. 'food_varieties' => 'require',
  22. 'food_attr' => 'require',
  23. 'goods_sort' => 'require',
  24. 'goods_create_time' => 'require',
  25. 'goods_update_time' => 'require',
  26. ];
  27. protected $message = [
  28. 'goods_name' => '商品名不能为空',
  29. 'goods_img' => '商品图不能为空',
  30. 'food_silde' => '轮播图不能为空',
  31. 'goods_category_id' => '所属分类不能为空',
  32. 'goods_shop_id' => '所属店铺不能为空',
  33. 'goods_is_new' => 'goods_is_new不能为空',
  34. 'goods_price' => '价格不能为空',
  35. 'goods_content' => '详情不能为空',
  36. 'goods_sell_num' => '销量不能为空',
  37. 'goods_postage_id' => '运费模板不能为空',
  38. 'goods_status' => '状态不能为空',
  39. 'goods_weight' => '重量不能为空',
  40. 'food_storage' => '储存方式不能为空',
  41. 'food_packaging' => '包装方式不能为空',
  42. 'food_varieties' => '品种不能为空',
  43. 'food_attr' => '规格不能为空',
  44. 'goods_sort' => '排序不能为空',
  45. 'goods_create_time' => '创建时间不能为空',
  46. 'goods_update_time' => '更新时间不能为空',
  47. ];
  48. //场景
  49. protected $scene = [
  50. 'create' => ['goods_name','goods_img','food_silde','goods_category_id','goods_shop_id','goods_is_new','goods_price','goods_content','goods_postage_id','goods_weight','goods_sort'],
  51. 'update' => ['goods_id'],
  52. 'info' => ['goods_id']
  53. ];
  54. }