Esempio n. 1
0
 protected function importTags($from, $to)
 {
     $colors = ['#F16655', '#F59B66', '#4E89DA', '#5AC169', '#96A2AF'];
     $this->info('Importing tags...');
     $to->table('tags')->truncate();
     $channels = $from->table('channel')->orderBy('lft')->get();
     $progress = new ProgressBar($this->output, count($channels));
     $i = 0;
     foreach ($channels as $c) {
         $tag = new Tag();
         $tag->id = $c->channelId;
         $tag->name = $c->title;
         $tag->slug = $c->slug;
         $tag->description = $c->description;
         $tag->color = $colors[$i++ % count($colors)];
         $tag->discussions_count = $c->countConversations;
         $tag->position = $c->lft;
         $tag->save();
         $progress->advance();
     }
     $progress->finish();
     $this->info("\n");
 }