FoodValidate.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace app\admin\validate\life;
  3. use think\Validate;
  4. class FoodValidate extends Validate
  5. {
  6. protected $rule = [
  7. 'food_name' => 'require|max:20',
  8. 'food_id' => 'require',
  9. 'food_content' => 'require',
  10. 'food_img' => 'require',
  11. 'food_category_id' => 'require',
  12. 'food_price' => 'require',
  13. 'food_pack_price' => 'require',
  14. 'food_label' => 'require',
  15. 'food_type' => 'require',
  16. 'food_status' => 'require',
  17. ];
  18. protected $message = [
  19. 'food_id.require' => '健康美食ID不能为空',
  20. 'food_name.require' => '健康美食名称不能为空',
  21. 'food_content.require'=> '健康美食详情不能为空',
  22. 'food_img.require' => '健康美食图片不能为空',
  23. 'food_name.max' => '健康美食名称不能超过20字',
  24. 'food_category_id.require' => '健康美食分类不能为空',
  25. 'food_price.require' => '健康美食价格不能为空',
  26. 'food_pack_price.require' => '打包价格不能为空',
  27. 'food_label.require' => '健康美食标签不能为空',
  28. 'food_type.require' => '健康美食类型不能为空',
  29. 'food_status.require' => '健康美食状态不能为空',
  30. ];
  31. //场景
  32. protected $scene = [
  33. 'create' => ['food_name','food_img','food_price','food_category_id','food_pack_price','food_label','food_content','food_type','food_status'],
  34. 'update' => ['food_id','food_name','food_img','food_price','food_category_id','food_pack_price','food_label','food_content','food_type','food_status'],
  35. 'info' => ['food_id']
  36. ];
  37. }