/**
  * Create a new match
  *
  * @param  int  $id
  * @return Response
  */
 public function storeMatch(Request $request)
 {
     $league_id = Input::get('league_id');
     $match_date = Input::get('match_date');
     $player1_id = Input::get('player1_id');
     $player2_id = Input::get('player2_id');
     $p1_score = Input::get('p1_score');
     $p2_score = Input::get('p2_score');
     $match_date = new \DateTime($match_date);
     $match_date = $match_date->format("Y-m-d h:m:s");
     if (!is_null($player1_id) && !is_null($player2_id)) {
         //create a new match
         $match = new Match();
         $match->player1_id = $player1_id;
         $match->player2_id = $player2_id;
         $match->match_date = $match_date;
         if ($p1_score > $p2_score) {
             $match->winner_id = $player1_id;
         } else {
             $match->winner_id = $player2_id;
         }
         $match->save();
         //Add match to the current league
         $league_match = new LeagueMatch();
         $league_match->league_id = $league_id;
         $league_match->match_id = $match->match_id;
         $league_match->save();
         //Create a game and add to the Match
         if (!is_null($p1_score) && !is_null($p2_score)) {
             $game = new Game();
             $game->score1 = $p1_score;
             $game->score2 = $p2_score;
             $game->save();
             $match_game = new MatchGame();
             $match_game->match_id = $match->match_id;
             $match_game->game_id = $game->id;
             $match_game->game_num = 1;
             //will be based on league format
             $match_game->save();
         }
     }
     //Redirect to add more matches; add Save Message
     return \Redirect::route('tools.league.match.create', array($league_id))->with('success', 'Match created Successfully');
 }