/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $match = new Match();
     $match->id = Input::get('id');
     $match->url = Input::get('url');
     $match->a = Input::get('a');
     $match->b = Input::get('b');
     $match->save();
     echo 'match saved';
 }
 public function save($data1, $data2, $data3, $data4, $data5, $data6)
 {
     $match = new Match();
     $match->team_1 = $data1;
     $match->score_team_1 = $data2;
     $match->team_2 = $data3;
     $match->score_team_2 = $data4;
     $match->date = $data5;
     $match->id_calendar = $data6;
     $match->save();
 }
 /**
  * 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');
 }
Esempio n. 4
0
 /**
  * Save a match to the provided event
  *
  * @return redirect
  **/
 public function saveMatch(CreateMatchRequest $request, Event $event)
 {
     $match = new Match();
     $match->match_type_id = MatchType::where('identifier', $event->type)->first()->id;
     $match->event_id = $event->id;
     $match->save();
     // if there is a team selected then we're going with teams.
     if ($request->teamBlack) {
         $match->teams()->save(Team::find($request->teamBlack));
         $match->teams()->save(Team::find($request->teamYellow));
     } elseif ($request->playersBlack) {
         $teamBlack = new Team();
         $teamBlack->save();
         $teamYellow = new Team();
         $teamYellow->save();
         foreach ($request->playersBlack as $key => $playerId) {
             $teamBlack->players()->save(Player::find($playerId));
             $teamYellow->players()->save(Player::find($request->playersYellow[$key]));
         }
         $match->teams()->save($teamBlack);
         $match->teams()->save($teamYellow);
     }
     return redirect()->route('dashboard.events.single', $event->id)->with('app-success', 'Match created successfully.');
 }