if (empty($station)) { return Response::error('404'); } $teams = Team::all(); $stationRounds = Round::where('station_id', '=', $station->id)->get(); $teamsAdded = array(); $teamslist = array(); foreach ($stationRounds as $sr) { $teamsAdded[] = $sr->team->id; } foreach ($teams as $team) { if (!in_array($team->id, $teamsAdded)) { $teamslist[$team->id] = $team->name; } } $rounds = Round::where('station_id', '=', $station->id)->get(); return View::make('station', array('station' => $station, 'rounds' => $rounds, 'teamslist' => $teamslist)); }); }); /* |-------------------------------------------------------------------------- | Application 404 & 500 Error Handlers |-------------------------------------------------------------------------- | | To centralize and simplify 404 handling, Laravel uses an awesome event | system to retrieve the response. Feel free to modify this function to | your tastes and the needs of your application. | | Similarly, we use an event to handle the display of 500 level errors | within the application. These errors are fired when there is an | uncaught exception thrown in the application.
/** * nextRound * Returns false if there is no next round (you're in the championship round.) * Get the round that is one index higher than the current round. * * @param Round $round Current round. * @return Round */ public function nextRound(Round $round) { return Round::where('bracket_id', '=', $round->bracket()->first()->id)->where('index', '=', $round->index + 1)->first(); }