作者 lyh

gx

@@ -72,9 +72,12 @@ class BlogCategoryLogic extends BaseLogic @@ -72,9 +72,12 @@ class BlogCategoryLogic extends BaseLogic
72 //随机获取最后一级id 72 //随机获取最后一级id
73 $replacement = $this->getLastId($id); 73 $replacement = $this->getLastId($id);
74 if($blogCount > 0){ 74 if($blogCount > 0){
  75 + if($replacement == $pid){
  76 + $replacement = ',';
  77 + }
75 //存在博客时,移动所有博客到当前分类最后一级 78 //存在博客时,移动所有博客到当前分类最后一级
76 $blogModel->where('category_id', 'like', '%,' . $pid . ',%') 79 $blogModel->where('category_id', 'like', '%,' . $pid . ',%')
77 - ->update(['category_id' => DB::raw("REPLACE(category_id, '$pid', '$replacement')")]); 80 + ->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', '$replacement')")]);
78 } 81 }
79 } 82 }
80 return $this->success(); 83 return $this->success();