|
@@ -11,6 +11,12 @@ class Goods extends Validate
|
|
|
*/
|
|
|
protected $rule = [
|
|
|
'orderby' => 'in:weigh,sales,price,views,comments',
|
|
|
+ 'orderway' => 'in:asc,desc',
|
|
|
+ 'pageSize' => 'integer|between:1,100',
|
|
|
+ 'page' => 'integer|between:1,100',
|
|
|
+ 'keywords' => 'string|max:255',
|
|
|
+ 'category_id' => 'integer',
|
|
|
+ 'brand_id' => 'integer',
|
|
|
];
|
|
|
|
|
|
/**
|
|
@@ -18,12 +24,21 @@ class Goods extends Validate
|
|
|
*/
|
|
|
protected $message = [
|
|
|
'orderby.in' => '排序字段只能是权重、销量、价格、浏览数或评论数',
|
|
|
+ 'orderway.in' => '排序方式只能是升序或降序',
|
|
|
+ 'pageSize.integer' => '页码必须是整数',
|
|
|
+ 'pageSize.between' => '页码必须在1到100之间',
|
|
|
+ 'page.integer' => '页码必须是整数',
|
|
|
+ 'page.between' => '页码必须在1到100之间',
|
|
|
+ 'keywords.string' => '关键词必须是字符串',
|
|
|
+ 'keywords.max' => '关键词长度不能超过255个字符',
|
|
|
+ 'category_id.integer' => '分类ID必须是整数',
|
|
|
+ 'brand_id.integer' => '品牌ID必须是整数',
|
|
|
];
|
|
|
|
|
|
/**
|
|
|
* 验证场景
|
|
|
*/
|
|
|
protected $scene = [
|
|
|
- 'lists' => ['orderby'],
|
|
|
+ 'lists' => ['orderby', 'orderway', 'pageSize', 'page', 'keywords', 'category_id', 'brand_id'],
|
|
|
];
|
|
|
}
|