/** * Display all the challenges * * @param App\Repositories\ChallengeRepository $challengeRepo * @param App\Repositories\GameRepository $gameRepo * @param Illuminate\Http\Request $request * * @return Response */ public function index(ChallengeRepository $challengeRepo, GameRepository $gameRepo, Request $request) { $active_game = null; if ($request->get('game')) { $challenges = $challengeRepo->byGame($request->get('game')); $active_game = $request->get('game'); } else { $challenges = $challengeRepo->fetchAll(); } return view('challenges.index', ['challenges' => $challenges, 'games' => $gameRepo->fetchAll(), 'active_game' => $active_game]); }