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