update cms category
This commit is contained in:
parent
bcfb184618
commit
d6e5fa091a
@ -61,7 +61,7 @@ class Category extends BaseModel
|
|||||||
'deleted_at',
|
'deleted_at',
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $updateChildrenFields = 'status';
|
protected $updateChildrenFields = ['status'];
|
||||||
|
|
||||||
const LIST_TYPE = 1; // 列表
|
const LIST_TYPE = 1; // 列表
|
||||||
const PAGE_TYPE = 2; // 单页
|
const PAGE_TYPE = 2; // 单页
|
||||||
|
@ -48,10 +48,14 @@ trait CategoryEvent
|
|||||||
*/
|
*/
|
||||||
public static function onBeforeUpdate(\think\Model $category)
|
public static function onBeforeUpdate(\think\Model $category)
|
||||||
{
|
{
|
||||||
$where = $category->getWhere();
|
$data = $category->getData();
|
||||||
|
|
||||||
if (self::where('name', $category->getData('name'))->where('id', '<>', $where['id'])->find()) {
|
if (isset($data['name'])) {
|
||||||
throw new FailedException('分类名称重复,请重新填写');
|
$where = $category->getWhere();
|
||||||
|
|
||||||
|
if (self::where('name', $category->getData('name'))->where('id', '<>', $where['id'])->find()) {
|
||||||
|
throw new FailedException('分类名称重复,请重新填写');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user