ProductValidate.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace app\admin\validate\healthy;
  3. use support\Validate;
  4. class ProductValidate extends Validate
  5. {
  6. protected $rule = [
  7. 'product_id' => 'require|integer',
  8. 'product_category_id' => 'require|integer',
  9. 'product_shop_id' => 'require|integer',
  10. 'product_name|产品名称' => 'require',
  11. 'product_price|价格' => 'require|float',
  12. 'product_freight_fee|运费' => 'require|float',
  13. 'product_postage_id|运费模板' => 'require|integer',
  14. 'product_packing_fee|打包费' => 'require|float',
  15. 'product_weight|重量' => 'require|float',
  16. 'product_image|图片' => 'regex:/^[0-9a-zA-Z\.\/]+$/',
  17. 'product_image_slide|轮播图' => 'regex:/^[0-9a-zA-Z\.\/\,]+$/',
  18. 'product_limit|限制内容' => 'max:150',
  19. 'product_notice|产品须知' => 'max:150',
  20. 'product_guarantee|产品保障' => 'max:150',
  21. 'product_type|产品类型' => 'in:0,1',
  22. 'product_status|状态' => 'in:0,1',
  23. 'product_audit|审核' => 'in:0,1,2',
  24. 'product_sort|排序' => 'require|integer',
  25. 'product_reject_reason' => 'max:255'
  26. ];
  27. protected $message = [];
  28. protected $scene = [
  29. 'add' => ['product_category_id', 'product_shop_id', 'product_name', 'product_price', 'product_freight_fee', 'product_postage_id',
  30. 'product_packing_fee', 'product_weight', 'product_image', 'product_image_slide', 'product_limit', 'product_notice',
  31. 'product_guarantee', 'product_type', 'product_status', 'product_audit', 'product_sort'],
  32. 'update' => ['product_id', 'product_category_id', 'product_shop_id', 'product_name', 'product_price', 'product_freight_fee',
  33. 'product_postage_id', 'product_packing_fee', 'product_weight', 'product_image', 'product_image_slide', 'product_limit',
  34. 'product_notice', 'product_guarantee', 'product_type', 'product_status', 'product_audit', 'product_sort','product_reject_reason'],
  35. ];
  36. }