public function show($id) { $game = Game::with('playthroughs', 'playthroughs.players')->find($id); $bgg = new \App\Bgg(); $api = $bgg->getBoardGame($game->bgg_id); return view('game.show', ['game' => $game, 'details' => $api]); }
public static function getPreviousWinner() { $game = Game::with('winner')->where('status', Game::STATUS_FINISHED)->orderBy('created_at', 'desc')->first(); $winner = null; if (!is_null($game)) { $winner = ['user' => $game->winner, 'price' => $game->price, 'chance' => self::_getUserChanceOfGame($game->winner, $game)]; } return $winner; }
public function game($gameId) { if (isset($gameId) && Game::where('status', Game::STATUS_FINISHED)->where('id', $gameId)->count()) { $game = Game::with(['winner'])->where('status', Game::STATUS_FINISHED)->where('id', $gameId)->first(); $game->ticket = floor($game->rand_number * ($game->price * 100)); $bets = $game->bets()->with(['user', 'game'])->get()->sortByDesc('created_at'); $chances = []; $percents = $this->_getChancesOfGame($game, true); return view('pages.game', compact('game', 'bets', 'chances', 'percents')); } return redirect()->route('index'); }
/** * List all games. * * @return Response */ public function index() { $game = Game::with('Scores')->get(); $this->tpl['games'] = $game; return view('game.list', $this->tpl); }