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 function indexGames() { $games = Game::get(); $bgg = new \App\Bgg(); $uploadr = new \App\Uploadr(); foreach ($games as $game) { $url = 'http:' . $bgg->getGameImage($game->bgg_id); $path = $uploadr->uploadFromUrl($url, $game->id, 'game'); $game->photo = $path; $game->save(); } return redirect()->back(); }
Route::get('admin/roles/create', ['uses' => 'AdminController@createRole', 'as' => 'admin.roles.create']); Route::post('admin/roles/create', ['uses' => 'AdminController@storeRole', 'as' => 'admin.roles.store']); Route::post('admin/roles/update', ['uses' => 'AdminController@updateRole', 'as' => 'admin.roles.update']); Route::get('admin/permissions', ['uses' => 'AdminController@permissions', 'as' => 'admin.permissions']); Route::get('admin/permissions/create', ['uses' => 'AdminController@createPermission', 'as' => 'admin.permissions.create']); Route::post('admin/permissions/update', ['uses' => 'AdminController@updatePermission', 'as' => 'admin.permissions.update']); Route::get('admin/users', ['uses' => 'AdminController@users', 'as' => 'admin.users']); Route::get('admin/user/edit/{id}', ['uses' => 'AdminController@user', 'as' => 'admin.user.edit']); Route::get('admin/game/index', ['uses' => 'AdminController@indexGames', 'as' => 'admin.game.index']); /* Register and Login */ Route::get('auth/login', 'Auth\\AuthController@getLogin'); Route::post('auth/login', 'Auth\\AuthController@postLogin'); Route::get('auth/logout', 'Auth\\AuthController@getLogout'); Route::controllers(['password' => 'Auth\\PasswordController']); Route::get('api/game/{id}', ['as' => 'api.game', function ($id) { $bgg = new \App\Bgg(); $bgg->getBoardGame($id); //return response()->json( $bgg->getBoardGame($id), 200, [], JSON_PRETTY_PRINT ); }]); Route::get('api/search/{text}', ['as' => 'api.search', function ($text = null) { $bgg = new \App\Bgg(); return response()->json($bgg->search($text), 200, [], JSON_PRETTY_PRINT); }]); Route::get('api/playthrough/players/{id}', ['as' => 'api.players', function ($id) { $st = ""; $players = Playthrough::find($id)->participants; foreach ($players as $p) { $st .= $p->id . ','; } return $st; }]);