Publish a source file and/or pass to $next.

@param Source $source
@param Closure $next
@param array $extensions
@return mixed
191104
public function handle(Source $source, Closure $next, ...$extensions)
    {
        if ($this->isPublishable($source, $extensions)) {

            $view = new View(
                $this->factory,
                $this->factory->getEngineFromPath($source->getPathname()),
                $this->files->get($source->getPathname()),
                $source->getPathname()
            );

            $source->changeExtension(['.blade.php' => '.html'])
                   ->changeExtension(['.php' => '.html']);

            $this->write(
                $source->getOutputPathname(),
                $view->render()
            );

        }

        $next($source);
    }
727243
public function handle($request, Closure $next)
    {
        // If GET request ends in a number, redirect
        if ($request->method() == 'GET'
            && ($url = $request->url())
            && preg_match('#/\d+$#', $url)) {
            return Redirect::to($url.'/edit');
        }

        // Chain
        return $next($request);
    }
329398
public function handle($request, Closure $next)
    {
        try {
            $response = $next($request);
        } catch (Exception $e) {
            $response = $this->handleException($request, $e);
        }

        if ($this->sentMail() && $response instanceof Response) {
            $this->appendToResponse($response);
        }

        return $response;
    }
204720
public function handle( $request, Closure $next )
    {
        if( $this->isAllowedIp( $request ) )
        {
            return $next( $request );
        }

        return abort( 403 );
    }
1374348
public static function addExtension(string $file, string $extension)
    {
        if (substr($file, strlen($extension) * -1) !== $extension) {
            $file .= $extension;
        }
        return $file;
    }
702526
public function handle($request, Closure $next)
    {
        $request->setTrustedProxies([
            $request->getClientIp(),
        ]);

        if (!$request->secure() && app()->environment('production')) {
                return redirect()->secure($request->getRequestUri());
        }

        return $next($request);
    }
1209235
public function withExtensions(Extensions $extensions): self
    {
        $obj = clone $this;
        $obj->_extensions = $extensions;
        return $obj;
    }
1068959
public function handle($request, Closure $next, $site)
    {
        Config::set('multisite.site', $site);

        return $next($request);
    }
290941
public function handle($request, Closure $next)
    {
        if ($theme = $request->query('cms-theme')) {
            $finder   = app('themes.view.finder');
            $basePath = config('themes.path.frontend', base_path('themes/frontend'));
            $finder->removeBasePath();
            $finder->setBasePath($basePath . DIRECTORY_SEPARATOR . $theme);

            config(['themes.frontend' => $theme]);
        }

        return $next($request);
    }
1361234
public function handle($request, \Closure $next)
    {
        $config = app('config');
        $view   = app('view');
        $domain = str_replace($config->get('tenancy.multi_site.ignorable_domain_components', []), '', $request->getHost());
        $tenant = $this->repository->findOneByDomain($domain);

        if (!$tenant instanceof TenantParticipant) {
            throw new \RuntimeException(
                sprintf('Unable to resolve host "%s" to valid TenantParticipant.', $domain)
            );
        }

        $finder = $view->getFinder();
        if ($finder instanceof TenantViewFinder) {
            $paths = $this->appendPathsInFinder($finder, $tenant);
        } else {
            $paths = $this->registerPathsInFinder($view, $finder, $tenant);
        }

        // update app config
        $config->set('app.url',    $request->getHost());
        $config->set('view.paths', array_merge($config->get('view.paths', []), $paths));

        // bind resolved tenant data to container
        app('auth.tenant')->updateTenancy(new NullUser(), $tenant->getTenantOwner(), $tenant);

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

        $this->corsProfile->setRequest($request);

        if (! $this->corsProfile->isAllowed()) {
            return $this->forbiddenResponse();
        }

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

        $response = $next($request);

        return $this->corsProfile->addCorsHeaders($response);
    }
764238
public function handle($request, Closure $next, $permissions)
    {
        $abilities = is_array($permissions) ? $permissions : explode(',', $permissions);

        if (! auth()->check() || ! auth()->user()->canAtLeast($abilities)) {
            abort(403, 'You are not allowed to view this content!');
        }

        return $next($request);
    }
1242981
public function addExtensions(Extension ...$extensions): void
    {
        foreach ($extensions as $extension)
        {
            $this->extensions->attach($extension);
        }
    }
594138
protected function set($name, \Closure $extension)
    {
        $this->getExtensions()->set($name, $extension);
        
        return $this;
    }
456275
public function handle($request, Closure $next)
    {

        if(!Storage::disk('local')->has('installed.txt')) {
            return redirect()->to('/install');
        }
        //todo check in middleware
        $installFile = Storage::disk('local')->has('installed.txt');
        if('.installed' != $installFile) {
            return redirect()->to('/install');
        }


        return $next($request);
    }
1021022
public function source($source, $sourceType = 'local')
    {
        $this->sourcePath = $source;
        $this->sourceType = $sourceType;

        return $this;
    }
463485
public function handle($request, \Closure $next)
    {
        $route = $request->route();

        if ($route->hasCondition()) {
            $this->router->addWordPressBindings($route);
        }

        return $next($request);
    }