浏览代码

支持attr

kphcdr 1 年之前
父节点
当前提交
3eb97315b2
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      app/Modules/Admin/Services/CategoryService.php

+ 4 - 0
app/Modules/Admin/Services/CategoryService.php

@@ -77,6 +77,10 @@ class CategoryService extends BaseService
     {
         $category = Category::findOrFail($params['id']);
 
+        if ($category->level == 1) {
+            throw new ClientException("一级类目不能删除");
+        }
+
         if ($count = Category::where("parent_id", $category->id)->count() > 0) {
             throw new ClientException("该类目下还有{$count}个子分类,请先删除子类目");
         }