Exemplo n.º 1
0
 public function get_generate_tournament()
 {
     $bracket = Bracket::find(Session::get('bracketId'));
     // If the bracket doesn't exist
     // redirect back on home
     if (!$bracket) {
         return Redirect::home();
     }
     // if there are no players
     // redirect to add players
     if (!$bracket->players) {
         return Redirect::to('bracket/players')->with('error', 'You do not have enough players to make a bracket.');
     }
     // if there are no players
     // redirect to add players
     if (!$bracket->teams) {
         return Redirect::to('bracket/players')->with('error', 'Pick teams to generate a new tournament bracket.');
     }
     // create the tournament object
     $tournament = new Tournament($bracket);
     // build the bracket and update the DB.
     $tournament->buildBracket();
     return Redirect::to('bracket/tournament');
 }