Ejemplo n.º 1
0
 private function all()
 {
     $overwrite = $this->option('o');
     if ($overwrite) {
         Setlist::truncate(['Setlist.id' => '!= ""']);
     }
     $continue = true;
     $p = 1;
     $inserted = 0;
     $setlistsPerPage = 20;
     while ($continue) {
         $xml = simplexml_load_file(Config::get('app.setlistfm_api_baseurl') . 'user/' . env('SETLISTFM_USER') . '/attended.xml?p=' . $p);
         $xmlChildren = $xml->children();
         $xmlChildrenCount = count($xmlChildren);
         if ($xmlChildrenCount < $setlistsPerPage) {
             $continue = false;
         }
         foreach ($xmlChildren as $xmlChild) {
             $id = (string) $xmlChild->attributes()->id;
             if (!$overwrite) {
                 $inDb = Setlist::where('id', $id)->first();
                 if ($inDb) {
                     continue;
                 }
             }
             $transformer = new SetlistTransformer();
             $setlist = $transformer->transform($xmlChild);
             $setlist->save();
             $inserted++;
             $this->showInfo($setlist);
         }
         $p++;
     }
     if ($inserted == 0) {
         $this->info('No setlists pending.');
     }
 }
Ejemplo n.º 2
0
 public function getView($id)
 {
     return view('setlists/view', ['setlist' => Setlist::where('id', $id)->first()]);
 }