作者 lyh

gx

@@ -68,16 +68,16 @@ class BlogCategoryLogic extends BaseLogic @@ -68,16 +68,16 @@ class BlogCategoryLogic extends BaseLogic
68 if($info['pid'] != $pid){ 68 if($info['pid'] != $pid){
69 //修改勒上级,先查看上级是否拥有博客 69 //修改勒上级,先查看上级是否拥有博客
70 $blogModel = new BlogModel(); 70 $blogModel = new BlogModel();
71 - $blogCount = $blogModel->formatQuery(['category_id'=>['like','%,'.$pid.',%']])->count(); 71 + $blogList = $blogModel->list(['category_id'=>['like','%,'.$pid.',%']],'id',['id','category_id']);
72 //随机获取最后一级id 72 //随机获取最后一级id
73 $replacement = $this->getLastId($id); 73 $replacement = $this->getLastId($id);
74 - if($blogCount > 0){  
75 - if($replacement == $pid){  
76 - $replacement = ','; 74 + if(!empty($blogList)){
  75 + foreach ($blogList as $v){
  76 + str_replace($pid,$replacement);
77 } 77 }
78 //存在博客时,移动所有博客到当前分类最后一级 78 //存在博客时,移动所有博客到当前分类最后一级
79 $blogModel->where('category_id', 'like', '%,' . $pid . ',%') 79 $blogModel->where('category_id', 'like', '%,' . $pid . ',%')
80 - ->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', '$replacement')")]); 80 + ->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',$replacement,')")]);
81 } 81 }
82 } 82 }
83 return $this->success(); 83 return $this->success();