/**
  *   Change the attempts status
  *
  *   @param App\Http\Requests\FinishAttemptReques $request
  *   @param App\Repositories\ChallengeRepository $challengeRepo
  *   @param App\Attempt $attempt
  *
  *   @note We don't update the success counter until it has been verified by a moderator
  *
  *   @return response
  */
 public function finish(FinishAttemptRequest $request, ChallengeRepository $challengeRepo, Attempt $attempt)
 {
     $attempt->status = strtoupper($request->status);
     $attempt->save();
     if ($request->status === 'failed') {
         $challengeRepo->incrementFailCounter($attempt->challenge_id);
     }
     return redirect()->route('attempts.show', [$attempt])->with($request->status, $request->status === 'success' ? 'Sweet, good job! We\'ll verify this asap.' : 'Dang, too bad.');
 }
 /**
  *   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]);
 }