adjustSequentAll(); return 1; } /** * 调整所有顺序 */ public function adjustSequentAll(){ set_time_limit(0); Book::where('last_cid','!=',0)->where('id','>=',807)->select('id')->get()->map(function ($item, $key){ $this->adjustSequentOne($item->id); }); } /** * 调整单本书的顺序 * @param $bid */ public function adjustSequentOne($bid){ $chapter_list = Chapter::getChapterLists($bid); $prev = 0; foreach ($chapter_list as $chapter){ if($prev){ Chapter::where('id',$chapter->id)->update(['prev_cid'=>$prev]); Chapter::where('id',$prev)->update(['next_cid'=>$chapter->id]); } $prev = $chapter->id; } } }