orderBy('book')->orderBy('paragraph')->cursor(); $pageHead = ['M','P','T','V','O']; $bar = $this->output->createProgressBar(WbwTemplate::where('type','.ctl.')->count()); foreach ($table as $key => $value) { $type = substr($value->word,0,1); if(in_array($type,$pageHead)){ $arrPage = explode('.',$value->word); if(count($arrPage)!==2){ continue; } $page = PageNumber::firstOrNew( [ 'book'=>$value->book, 'paragraph'=>$value->paragraph, 'wid'=>$value->wid, ], [ 'type'=>$type, 'volume'=>(int)substr($arrPage[0],1), 'page'=>(int)$arrPage[1], 'pcd_book_id'=>$value->pcd_book_id, ] ); $page->save(); } $bar->advance(); } $bar->finish(); return 0; } }