refactor: 修改横幅(分类)关于唯一标识验证规则
This commit is contained in:
@@ -69,7 +69,7 @@ class Banner
|
|||||||
'name',
|
'name',
|
||||||
'desc',
|
'desc',
|
||||||
'recommend',
|
'recommend',
|
||||||
'unique_label' => '',
|
'unique_label',
|
||||||
'at_platform' => 'pc',
|
'at_platform' => 'pc',
|
||||||
'status' => 1
|
'status' => 1
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -51,26 +51,22 @@ class SysBannerValidate extends Validate
|
|||||||
// 新增场景
|
// 新增场景
|
||||||
public function sceneAdd()
|
public function sceneAdd()
|
||||||
{
|
{
|
||||||
return $this->remove('id', 'require|integer');
|
return $this->remove('id', 'require|integer')->append('unique_label', 'require');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 编辑场景
|
// 编辑场景
|
||||||
public function sceneEdit()
|
public function sceneEdit()
|
||||||
{
|
{
|
||||||
return $this->remove('language_id', 'require|integer')->append('unique_label', 'empty');
|
return $this->remove('language_id', 'require|integer')->append('unique_label', 'mustOmit');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 验证是否为空
|
// 验证是否为空
|
||||||
protected function empty($value, $rule, $data)
|
protected function mustOmit($value, $rule, $data)
|
||||||
{
|
{
|
||||||
if (!isset($data['unique_label'])) {
|
if (!isset($data['unique_label'])) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($value) || $value == '') {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return "unique_label必须为空";
|
return "unique_label必须为空";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user