/**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $userLogic = new Logic();
     if ($userLogic->get()) {
         return redirect()->route('lobby');
     }
     return $next($request);
 }
 public function join(Request $request, Logic $userLogic)
 {
     $username = $request->input('username');
     // check if taken by other joins
     if (in_array($username, $userLogic->online() || User::where('username', $username)->count())) {
         return redirect()->back()->withErrors(['username' => trans('game.username.inuse')]);
     }
     $userLogic->register($username);
     return redirect()->route('lobby');
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     $userLogic = new Logic();
     if (!$userLogic->get()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->guest(route('home'));
         }
     }
     return $next($request);
 }