refactor: 修改横幅(分类)关于唯一标识验证规则
This commit is contained in:
@@ -51,26 +51,22 @@ class SysBannerValidate extends Validate
|
||||
// 新增场景
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id', 'require|integer');
|
||||
return $this->remove('id', 'require|integer')->append('unique_label', 'require');
|
||||
}
|
||||
|
||||
// 编辑场景
|
||||
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'])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (is_null($value) || $value == '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return "unique_label必须为空";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user