作者 lyh

gx

@@ -71,11 +71,9 @@ class BlogCategoryLogic extends BaseLogic @@ -71,11 +71,9 @@ class BlogCategoryLogic extends BaseLogic
71 $blogModel = new BlogModel(); 71 $blogModel = new BlogModel();
72 $blogCount = $blogModel->formatQuery(['category_id'=>['like','%,'.$pid.',%']])->count(); 72 $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); 73 @file_put_contents(storage_path('logs/lyh_error.log'), var_export(222222, true) . PHP_EOL, FILE_APPEND);
74 -  
75 //随机获取最后一级id 74 //随机获取最后一级id
76 $replacement = $this->getLastId($id); 75 $replacement = $this->getLastId($id);
77 @file_put_contents(storage_path('logs/lyh_error.log'), var_export(33333, true) . PHP_EOL, FILE_APPEND); 76 @file_put_contents(storage_path('logs/lyh_error.log'), var_export(33333, true) . PHP_EOL, FILE_APPEND);
78 -  
79 if($blogCount > 0){ 77 if($blogCount > 0){
80 //存在博客时,移动所有博客到当前分类最后一级 78 //存在博客时,移动所有博客到当前分类最后一级
81 $blogModel->where('category_id', 'like', '%,' . $pid . ',%')->where('category_id', 'like', '%,' . $replacement . ',%') 79 $blogModel->where('category_id', 'like', '%,' . $pid . ',%')->where('category_id', 'like', '%,' . $replacement . ',%')
@@ -83,8 +81,6 @@ class BlogCategoryLogic extends BaseLogic @@ -83,8 +81,6 @@ class BlogCategoryLogic extends BaseLogic
83 $blogModel->where('category_id', 'like', '%,' . $pid . ',%') 81 $blogModel->where('category_id', 'like', '%,' . $pid . ',%')
84 ->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',$replacement,')")]); 82 ->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',$replacement,')")]);
85 } 83 }
86 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export(44444, true) . PHP_EOL, FILE_APPEND);  
87 -  
88 } 84 }
89 return $this->success(); 85 return $this->success();
90 } 86 }
@@ -98,10 +94,12 @@ class BlogCategoryLogic extends BaseLogic @@ -98,10 +94,12 @@ class BlogCategoryLogic extends BaseLogic
98 */ 94 */
99 public function getLastId($id){ 95 public function getLastId($id){
100 $info = $this->model->read(['pid'=>$id],['id']); 96 $info = $this->model->read(['pid'=>$id],['id']);
101 - if($info !== false){  
102 - $this->getLastId($id); 97 + if($info == false){
  98 + return $this->getLastId($id);
  99 + }else{
  100 + return $id;
103 } 101 }
104 - return $id; 102 +
105 } 103 }
106 104
107 /** 105 /**