示例#1
0
 public function authorize($id)
 {
     $formData = Input::only('password');
     $this->gamePasswordForm->validate($formData);
     $game = Game::find($id);
     if ($error = $this->ensureJoinable($game)) {
         return Redirect::route('lobby_path')->withErrors($error);
     }
     if ($game->password != $formData['password']) {
         return Redirect::back()->withErrors('Incorrect Password');
     }
     $current_user = Auth::user();
     $playerCount = count($game->player);
     $player = new Player(['game_id' => $game->id, 'user_id' => $current_user->id, 'slot' => $playerCount + 1]);
     $player->save();
     return Redirect::route('match_path', $game->id);
 }
示例#2
0
 public function index()
 {
     $availableGames = Game::where('open', '=', 1)->get();
     return View::make('pages.lobby.index')->withSectionTitle('Lobby')->withAvailableGames($availableGames);
 }