/** * Adds a Game to the DB. * * @param str $name * * @return Game */ public function addGame($name) { $game = new Game(); $game->name = $name; $game->save(); return $game; }
public function postCreate() { $game = new Game(); $game->name = Request::input('name'); $game->year = Request::input('year'); $game->save(); return redirect('games'); }
public function saveGameStats(Game $game, array $stats) { $stats = $this->reformatStats($stats); foreach ($stats as $stat) { $stat['game_id'] = $game->id; $this->saveGameStat($stat); } $game->status = Game::getPlayedStatus(); $game->save(); }
public static function createGame($userRole, $data) { $game = new Game(); $game->team_id = $userRole; $game->home_team = $data['home_team']; $game->away_team = $data['away_team']; $game->date = $data['date']; $game->location = $data['location']; $game->save(); return $game; }
public static function createSession($data) { $game = new Game(); $game->team_id = $data['team_id']; $game->author = $data['user_id']; $game->date = $data['date']; $game->topic = $data['topic']; $game->aims = $data['aims']; $game->save(); return $game; }
public function actionRegister($gameName, $port, $hostname = null) { $ip = ip2long(Yii::$app->request->userIP); $Game = Game::find()->where(['ip_address' => $ip, 'port' => $port])->one(); if (!$Game) { $Game = new Game(); $Game->name = $gameName; $Game->ip_address = $ip; $Game->port = $port; } return $Game->save(); }
public function actionUpdateGame() { $data = Yii::$app->request->post(); $ip = ip2long(Yii::$app->request->userIP); foreach ($data['Games'] as $game) { $Game = Game::find()->where(['id' => $game['id'], 'ip_address' => $ip])->one(); if (!$Game) { $Game = new Game(); } $Game->attributes = $game; $Game->ip_address = $ip; $Game->save(); } return true; }
public function getGame($winner, $loser) { $winner = Team::where("abb", $winner)->first(); if ($winner != null) { $winner->wins++; $winner->games++; $winner->save(); $winnerKey = $winner->team_key; } $loser = Team::where("abb", $loser)->first(); if ($loser != null) { $loser->games++; $loser->save(); $loserKey = $loser->team_key; } if ($winner != null && $loser != null) { $game = new Game(); $game->winner = $winnerKey; $game->loser = $loserKey; $game->save(); } return "Ok"; }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { $game = new Game(); $game->DATA = $request->input("DATA"); $game->DRUZYNA_ID_DRUZYNA = $request->input("DRUZYNA_ID_DRUZYNA"); $game->DRUZYNA_ID_DRUZYNA2 = $request->input("DRUZYNA_ID_DRUZYNA2"); if ($game->DRUZYNA_ID_DRUZYNA == $game->DRUZYNA_ID_DRUZYNA2) { \Session::flash('alert-class', 'alert-danger'); return redirect()->route('games.index')->with('message', 'Błąd - wybierz 2 różne drużyny.'); } $game->GOL_DRUZYNA = $request->input("GOL_DRUZYNA"); $game->GOL_DRUZYNA1 = $request->input("GOL_DRUZYNA1"); $game->SEDZIA_ID_SEDZIA = $request->input("SEDZIA_ID_SEDZIA"); $game->STADIONY_ID_STADION = $request->input("STADIONY_ID_STADION"); $game->ROZGRYWKI_ID_ROZGRYWKI = $request->input("ROZGRYWKI_ID_ROZGRYWKI"); $game->save(); $id = $game->ID_MECZ; $team1 = $game->DRUZYNA_ID_DRUZYNA; $team2 = $game->DRUZYNA_ID_DRUZYNA2; $gol1 = $game->GOL_DRUZYNA; $gol2 = $game->GOL_DRUZYNA1; try { \DB::raw("call updateBuget({$id},{$team1},{$team2},{$gol1},{$gol2})"); } catch (QueryException $e) { } /* \DB::select('call updateBuget(?,?,?,?,?)',array( $game->ID_MECZ, $game->DRUZYNA_ID_DRUZYNA, $game->DRUZYNA_ID_DRUZYNA2, $game->GOL_DRUZYNA, $game->GOL_DRUZYNA1));*/ return redirect()->route('games.index')->with('message', 'Item created successfully.'); }