private function augmentShows() { $show = []; $shows = Show::orderBy('show_name')->get(); $client = new Client(); foreach ($shows as $show) { echo "Augmenting " . $show->show_name . "\r\n"; $res = $client->request('GET', 'http://thetvdb.com/api/' . getenv('POMPONG_THETVDB_APIKEY') . '/series/' . $show->id . '/en.xml', ['http_errors' => false]); if ($res->getStatusCode() == 200) { $body = $res->getBody(); $stringBody = (string) $body; $xml = simplexml_load_string($stringBody); $json = json_encode($xml); $tvShow = json_decode($json, TRUE); } else { continue; } if (gettype($tvShow['Series']['Overview']) == "string") { $show->overview = $tvShow['Series']['Overview']; } if (gettype($tvShow['Series']['banner']) == "string") { $show->image_url = $this->getImage('http://thetvdb.com/banners/' . $tvShow['Series']['banner'], $show->id); } $show->save(); } }
/** * Display a listing of the resource. * * @return Response */ public function index() { $shows = Show::orderBy('post_date', 'DESC')->simplePaginate(5); // DATES $today = Carbon::today()->formatLocalized('%A %B %d'); $yesterday = Carbon::now()->subDay()->formatLocalized('%A %B %d'); return view('shows')->with(compact('shows', 'today', 'yesterday')); }
/** * Show the application dashboard to the user. * * @return Response */ public function index() { $shows = Show::orderBy('post_date', 'DESC')->limit(3)->get(); $shows = $shows->reverse(); // DATES $today = Carbon::today()->formatLocalized('%A %B %d'); $yesterday = Carbon::now()->subDay()->formatLocalized('%A %B %d'); return view('home')->with(compact('shows', 'today', 'yesterday')); }