正在显示
1 个修改的文件
包含
4 行增加
和
2 行删除
| @@ -68,11 +68,13 @@ class BlogCategoryLogic extends BaseLogic | @@ -68,11 +68,13 @@ 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 | - $blogList = $blogModel->list(['category_id'=>['like','%,'.$pid.',%']],'id',['id','category_id']); | 71 | + $blogCount = $blogModel->formatQuery(['category_id'=>['like','%,'.$pid.',%']])->count(); |
| 72 | //随机获取最后一级id | 72 | //随机获取最后一级id |
| 73 | $replacement = $this->getLastId($id); | 73 | $replacement = $this->getLastId($id); |
| 74 | - if(!empty($blogList)){ | 74 | + if($blogCount > 0){ |
| 75 | //存在博客时,移动所有博客到当前分类最后一级 | 75 | //存在博客时,移动所有博客到当前分类最后一级 |
| 76 | + $blogModel->where('category_id', 'like', '%,' . $pid . ',%')->where('category_id', 'like', '%,' . $replacement . ',%') | ||
| 77 | + ->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',')")]); | ||
| 76 | $blogModel->where('category_id', 'like', '%,' . $pid . ',%') | 78 | $blogModel->where('category_id', 'like', '%,' . $pid . ',%') |
| 77 | ->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',$replacement,')")]); | 79 | ->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',$replacement,')")]); |
| 78 | } | 80 | } |
-
请 注册 或 登录 后发表评论