public function show($id) { $park = Cache::remember('park.' . $id . '.show', config('cache.general'), function () use($id) { return Park::findOrFail($id); }); return view('park.show')->with(['park' => $park, 'pageTitle' => $park->name]); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { // Get Park name and hours $now = Carbon::now(); $park = Park::find($id); $parkHours = $park->fetchHours($park->name, $now); // Set the closing time back to midnight if ($parkHours[1] == '11:59 p.m.') { $parkHours[1] = '12:00 p.m.'; } // Get ride information $rides = $park->rides; // Get the max wait time and distrubution $max = 0; $waitDist = new \StdClass(); $waitDist->low = 0; $waitDist->med = 0; $waitDist->high = 0; $waitDist->closed = 0; foreach ($rides as $ride) { if ($max < $ride->wait()) { $max = $ride->wait(); } if ($ride->wait() == 0) { $waitDist->closed++; } elseif ($ride->wait() < 20) { $waitDist->low++; } elseif ($ride->wait() < 45) { $waitDist->med++; } else { $waitDist->high++; } } $data['park'] = $park; $data['parkOpen'] = $parkHours[0]; $data['parkClose'] = $parkHours[1]; $data['rides'] = $rides; $data['waitMax'] = $max != 0 ? $max : 1; $data['waitDist'] = $waitDist; return View::make('parks.single', $data); }
/** * Fetches Park Hours * Used to test connectivity to disney site */ public function fetchParkHours($parkName = 'Disneyland') { $now = Carbon::now(); $park = new Park(); return \Response::json($park->fetchHours($parkName, $now)); }