refactor: 修改产品校验规则
This commit is contained in:
@@ -14,24 +14,25 @@ class ProductValidate extends Validate
|
||||
* @var array
|
||||
*/
|
||||
protected $rule = [
|
||||
'category_id' => 'integer',
|
||||
'spu' => 'require|max:255',
|
||||
'name' => 'require|max:125',
|
||||
'short_name' => 'max:64',
|
||||
'cover_image' => 'max:255',
|
||||
'desc' => 'max:255',
|
||||
'video_img' => 'max:255',
|
||||
'video_url' => 'max:255',
|
||||
'is_sale' => 'in:0,1',
|
||||
'is_new' => 'in:0,1',
|
||||
'is_hot' => 'in:0,1',
|
||||
'sort' => 'integer',
|
||||
'detail' => 'max:65535',
|
||||
'status' => 'in:-1,1',
|
||||
'seo_title' => 'max:255',
|
||||
'language_id' => 'require|integer',
|
||||
'category_id' => 'integer',
|
||||
'spu' => 'require|max:255',
|
||||
'name' => 'require|max:125',
|
||||
'short_name' => 'max:64',
|
||||
'cover_image' => 'max:255',
|
||||
'desc' => 'max:255',
|
||||
'video_img' => 'max:255',
|
||||
'video_url' => 'max:255',
|
||||
'is_sale' => 'in:0,1',
|
||||
'is_new' => 'in:0,1',
|
||||
'is_hot' => 'in:0,1',
|
||||
'sort' => 'integer',
|
||||
'detail' => 'max:65535',
|
||||
'status' => 'in:-1,1',
|
||||
'seo_title' => 'max:255',
|
||||
'seo_keywords' => 'max:255',
|
||||
'seo_desc' => 'max:255',
|
||||
'created_at' => 'checkFormatDatetimeRange'
|
||||
'seo_desc' => 'max:255',
|
||||
'created_at' => 'checkFormatDatetimeRange'
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -41,6 +42,8 @@ class ProductValidate extends Validate
|
||||
* @var array
|
||||
*/
|
||||
protected $message = [
|
||||
'language_id.require' => '语言ID不能为空',
|
||||
'language_id.integer' => '语言ID必须为整数',
|
||||
'category_id.integer' => '分类ID必须为整数',
|
||||
'spu.require' => 'spu不能为空',
|
||||
'spu.max' => 'spu不能超过255个字符',
|
||||
@@ -77,6 +80,7 @@ class ProductValidate extends Validate
|
||||
public function sceneUpdate()
|
||||
{
|
||||
return $this->only([
|
||||
'language_id',
|
||||
'category_id',
|
||||
'spu',
|
||||
'name',
|
||||
|
||||
Reference in New Issue
Block a user