|
...
|
...
|
@@ -66,12 +66,15 @@ class BlogCategoryLogic extends BaseLogic |
|
|
|
public function editHandleCategory($id,$pid){
|
|
|
|
$info = $this->model->read(['id'=>$id],['id','pid']);
|
|
|
|
if($info['pid'] != $pid){
|
|
|
|
@file_put_contents(storage_path('logs/lyh_error.log'), var_export(111, true) . PHP_EOL, FILE_APPEND);
|
|
|
|
//修改勒上级,先查看上级是否拥有博客
|
|
|
|
$blogModel = new BlogModel();
|
|
|
|
$blogCount = $blogModel->formatQuery(['category_id'=>['like','%,'.$pid.',%']])->count();
|
|
|
|
@file_put_contents(storage_path('logs/lyh_error.log'), var_export(2222, true) . PHP_EOL, FILE_APPEND);
|
|
|
|
if($blogCount > 0){
|
|
|
|
//随机获取最后一级id
|
|
|
|
$replacement = $this->getLastId($id);
|
|
|
|
@file_put_contents(storage_path('logs/lyh_error.log'), var_export(333, true) . PHP_EOL, FILE_APPEND);
|
|
|
|
//存在博客时,移动所有博客到当前分类最后一级
|
|
|
|
$blogModel->where('category_id', 'like', '%,' . $pid . ',%')->where('category_id', 'like', '%,' . $replacement . ',%')
|
|
|
|
->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',')")]);
|
...
|
...
|
|