code: public function handle($request, Closure $next)
      {
          if ($this->auth->guest()) {
              if ($request->ajax()) {
                  return $this->response->make('Unauthorized.', 401);
              } else {
                  return $this->redirect->guest($this->config->get('entrust-gui.unauthorized-url', 'auth/login'));
              }
          } elseif (! $request->user()->hasRole($this->config->get('entrust-gui.middleware-role'))) {
              return $this->response->make('Unauthorized.', 401); //Or redirect() or whatever you want
          }
          return $next($request);
      }
docs: Handle the request
  
  @param mixed $request
  @param Closure $next
  
  @return Response