refactor: 修改横幅(分类)关于唯一标识验证规则

This commit is contained in:
2025-03-13 09:56:26 +08:00
parent 78933cd7c3
commit 073b94d3b9
2 changed files with 4 additions and 8 deletions

View File

@@ -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
]); ]);

View File

@@ -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必须为空";
} }
} }