作者 lyh

gx

... ... @@ -71,11 +71,9 @@ class BlogCategoryLogic extends BaseLogic
$blogModel = new BlogModel();
$blogCount = $blogModel->formatQuery(['category_id'=>['like','%,'.$pid.',%']])->count();
@file_put_contents(storage_path('logs/lyh_error.log'), var_export(222222, true) . PHP_EOL, FILE_APPEND);
//随机获取最后一级id
$replacement = $this->getLastId($id);
@file_put_contents(storage_path('logs/lyh_error.log'), var_export(33333, true) . PHP_EOL, FILE_APPEND);
if($blogCount > 0){
//存在博客时,移动所有博客到当前分类最后一级
$blogModel->where('category_id', 'like', '%,' . $pid . ',%')->where('category_id', 'like', '%,' . $replacement . ',%')
... ... @@ -83,8 +81,6 @@ class BlogCategoryLogic extends BaseLogic
$blogModel->where('category_id', 'like', '%,' . $pid . ',%')
->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',$replacement,')")]);
}
@file_put_contents(storage_path('logs/lyh_error.log'), var_export(44444, true) . PHP_EOL, FILE_APPEND);
}
return $this->success();
}
... ... @@ -98,12 +94,14 @@ class BlogCategoryLogic extends BaseLogic
*/
public function getLastId($id){
$info = $this->model->read(['pid'=>$id],['id']);
if($info !== false){
$this->getLastId($id);
}
if($info == false){
return $this->getLastId($id);
}else{
return $id;
}
}
/**
* @remark :编辑路由时生成路由记录
* @name :editCategoryRoute
... ...