Handle an incoming request.

@param \Illuminate\Http\Request $request
@param \Closure $next
@param string $model
@param string $relation
@return mixed
421103
public function handle($request, Closure $next, $model, $relation)
    {
        $model = 'App\\' . $model;
        $params = array_values( $request->route()->parameters() );
        // eğer ikinci yoksa dön
        if ( ! isset($params[1])) {
            return $next($request);
        }

        $model = is_numeric($params[0]) ? $model::findOrFail($params[0]) : $params[0];
        $relation_id = is_numeric($params[1]) ? $params[1] : $params[1]->id;

        // baum mu değil mi ona göre query oluşturulur
        // pagecategory baum olduğunda buna gerek yok
        $parent = '\\'. get_parent_class($model);
        $query = get_parent_class(new $parent) === 'Baum\Node' ? $model->descendantsAndSelf() : $model->query();
        $relationModel = $query->whereHas($relation, function($query) use($relation_id)
        {
            return $query->whereId($relation_id);
        })->get();

        if ( $relationModel->isEmpty() ) {
            abort(404);
        }

        return $next($request);
    }
1306203
public function handle(Request $request, Closure $next)
    {
        // Are we going to try and include embedded data?
        $this->response->getManager()->parseIncludes(explode(',', $request->get('include')));

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

        return $next($request);
    }
891680
public function handle($request, Closure $next)
    {
        if ( ! $this->repository->isLocalized()) {
            return $next($request);
        }

        $locale = $this->getValidSessionLocale();

        if ( ! $locale && $this->core->config('locale.request-based')) {
            $locale = $this->getRequestLocale($request);
        }

        if ($locale) {
            app()->setLocale($locale);
        }

        return $next($request);
    }
1092459
public function handle($request, Closure $next)
    {
        $locale = $request->segment(1);

        $language = Language::findByCode($locale);

        if ($language) {
            App::setLocale($language->code);
            $request->setDefaultLocale($language->code);
        } else {
            $request->setDefaultLocale(config('app.locale'));
        }

        return $next($request);
    }
1040215
public function handle($request, Closure $next)
    {
        $this->kernel->setClosure($next);

        return $this->middleware->handle($request);
    }
4140
public function handle($request, Closure $next)
    {
        if (! $this->checkIfUserCanViewPost($request)) {
            return redirect()->route('/');
        }

        return $next($request);
    }
1002403
public function handle($request, Closure $next, $role)
    {
        $this->authorize($role);

        return $next($request);
    }
209437
public function handle($request, Closure $next)
    {

        if ($request->session()->has('language')) {
            $local = $request->session()->get('language', config('app.locale'));
            app()->setLocale($local);
        }

        return $next($request);
    }
1059794
public function handle($request, Closure $next)
    {
        $response = $next($request);

        if ($this->isAResponseObject($response) && $this->isAnHtmlResponse($response)) {
            $output = $response->getContent();
            $minified = $this->html->render($output);
            $response->setContent($minified);
        }

        return $response;
    }
52718
public function handle($request, Closure $next)
    {
        $response = $next($request);

        if ($response instanceof Response) {
            $response->isNotModified($request);
        }

        return $response;
    }
1231658
public function handle($request, Closure $next)
    {
        $this->authorizer->setRequest($request);

        $this->authorizer->checkAuthCodeRequest();

        return $next($request);
    }
1253502
public function handle(Request $request, Closure $next)
    {
        /** @var Response $response */
        $response = $request->isXmlHttpRequest() === true ? $next($request) : $this->createForbiddenResponse();

        return $response;
    }
1306936
public function handle($request, Closure $next)
    {
        if ($this->auth->parser()->setRequest($request)->hasToken()) {
            try {
                $this->auth->parseToken()->authenticate();
            } catch (Exception $e) {
                //
            }
        }

        return $next($request);
    }
285554
public function handle($request, Closure $next)
    {
        $route = $this->router->getCurrentRoute();

        if (! $this->auth->check(false)) {
            $this->auth->authenticate($route->getAuthenticationProviders());
        }

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

        $this->clean($request);

        return $next($request);
    }
217595
public function handle($request, Closure $next)
    {
        $this->app->setLocale($this->getCurrentLocale($request));

        return $next($request);
    }