/**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $mangaCount = Manga::count();
     $offset = 0;
     $limit = 1000;
     $this->output->progressStart($mangaCount);
     DB::beginTransaction();
     DB::table('manga_category')->delete();
     while ($offset < $mangaCount) {
         $mangas = Manga::select(['id', 'cat'])->orderBy('id', 'asc')->skip($offset)->take($limit)->get();
         foreach ($mangas as $manga) {
             foreach ($manga->cat as $catId) {
                 if ($catId != '') {
                     $mangaCategory = new MangaCategory();
                     $mangaCategory->mng_id = $manga->id;
                     $mangaCategory->cat_id = $catId;
                     $mangaCategory->save();
                 }
             }
             $this->output->progressAdvance();
         }
         $offset += $limit;
     }
     DB::commit();
     $this->output->progressFinish();
 }
Exemple #2
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $manga = Manga::with(['chapters' => function ($query) {
         $query->select(Chapter::$attrToSelect);
     }])->find($id, Manga::$detailAttrToSelect);
     return response()->json($manga->toArray(Manga::$detailAttrToOutput));
 }
Exemple #3
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $mangas = Manga::select(['id', 'ath'])->whereNull('authors')->get();
     $this->output->progressStart(count($mangas));
     foreach ($mangas as $manga) {
         $authorIds = explode(',', trim($manga->ath, ','));
         $authorNames = $this->getAuthorNames($authorIds);
         $manga->authors = $authorNames;
         $manga->save();
         $this->output->progressAdvance();
     }
     $this->output->progressFinish();
 }