Handle an incoming request.

@param \Illuminate\Http\Request $request
@param \Closure                 $next
@param string                   $type

@return mixed
348731
public function handle($request, Closure $next, $type)
    {
        if (!$this->typeResolver->hasType($this->tenant->getTenantCreator(), $type)) {
            return redirect()->route('tenant.tenant_type_not_supported', ['type' => $type]);
        }

        return $next($request);
    }
1301372
public function handle($request, Closure $next)
    {
        if ( ! $this->auth->check()) {

            if ($request->ajax() || $request->wantsJson()) {
                return response('Unauthorized.', 401);
            } else {
                /** @var CoreInterface $core */
                $core = app(Component::CORE);

                return redirect()->route( $core->prefixRoute(NamedRoute::AUTH_LOGIN) );
            }
        }

        return $next($request);
    }
462069
public function handle($request, Closure $next)
    {
        $token = $this->getTokenFromRequest($request);
        $this->jwt->setToken($token)->validateOrFail();

        return $next($request);
    }
890253
public function handle(Request $request, Closure $next)
    {
        if (!$this->service->isCorsRequest($request)) {
            return $next($request);
        }

        if ($this->service->isPreflightRequest($request)) {
            return $this->service->handlePreflightRequest($request);
        }

        return $this->service->handleRequest($request, $next($request));
    }
36178
public function handle($request, Closure $next)
    {
        $this->core->menu()->initialize();

        return $next($request);
    }
929465
public function handle($request, Closure $next)
    {
        Paginator::currentPageResolver(function () {
            return app('paginateroute')->currentPage();
        });

        return $next($request);
    }
635269
public function handle(Request $request, Closure $next)
    {
        /** @var Response $response */
        $response = $next($request);

        if ($this->stack->count() > 0) {
            $dumped = \implode(\PHP_EOL, $this->stack->all());

            $this->stack->clear();

            $response->setContent($dumped . $response->getContent());
        }

        return $response;
    }
380735
public function handle(Request $request, Closure $next)
    {
        $request->headers->set('Accept', 'application/json');

        return $next($request);
    }
653223
public function handle($request, \Closure $next)
    {
        if ($this->auth->check()) {
            return Redirect::route(config('society.user.config.redirect_route_after_login'));
        }

        return $next($request);
    }
491073
public function handle($request, Closure $next)
    {
        $request->setTrustedProxies(['127.0.0.1', $request->server->get('REMOTE_ADDR')]);

        return $next($request);
    }
855416
public function handle($request, \Closure $next)
    {
        $this->filter->add(
            'body_class',
            $this->dispatchBodyClass($request->route())
        );

        return $next($request);
    }
259493
public function handle(Request $request, Closure $next)
    {
        // set curent user preferences to Config
        if ($user = $request->user()) {
            Config::set('typicms.user', $user->preferences);
        }

        return $next($request);
    }
729059
public function handle($request, Closure $next)
    {
        $acceptLanguage = $request->header('Accept-Language');
        $locale = $this->getLocale($acceptLanguage);
        \App::setLocale($locale);
        return $next($request);
    }
1311928
public function handle($request, Closure $next)
    {
        // TODO: Get theme from user settings or system setting, or env or default....
        \Plugin::init();
        \Plugin::do_action('init');

        return $next($request);
    }
1197187
public function handle(Request $request, Closure $next)
    {
        $request::setTrustedProxies([$request->getClientIp()]);

        if (config('redirect.https', false) && !$request->secure())
        {
            return redirect()->secure($request->getRequestUri());
        }

        return $next($request);
    }
507341
public function handle($request, Closure $next)
    {
        /** @var Response $response */
        $response = $next($request);

        if ($request->isMethod('get')) {
            // Generate Etag
            $etag = md5($response->getContent());

            $requestEtag = str_replace('"', '', $request->getETags());
            // Check to see if Etag has changed
            if ($requestEtag && $requestEtag[0] == $etag) {
                $response->setNotModified();
            }

            // Set Etag
            $response->setEtag($etag);
        }

        return $response;
    }
801350
public function handle($request, Closure $next)
    {
        $this->attributes = array_slice(func_get_args(), 2);

        $this->clean($request);

        return $next($request);
    }