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