refactor: 视频分类删除检查分类下是否存在视频

This commit is contained in:
2025-02-21 09:40:50 +08:00
parent e9005bdb99
commit c4ef5530ab
2 changed files with 11 additions and 0 deletions

View File

@@ -149,6 +149,11 @@ class VideoCategory
return error('请确认操作对象是否存在');
}
// 检查该分类下是否存在视频
if ($category->video()->count()) {
return error('该分类下存在视频,请先删除视频');
}
if (!$category->delete()) {
return error('操作失败');
}