Apply the filter item.

@return void
499428
private static function applySearchFilter(&$query, $filter)
    {
        $filter_type = Arr::get($filter, 'settings.filter');
        $method = Arr::get($filter, 'method');
        $arguments = Arr::get($filter, 'arguments');
        $attributes = Arr::get($filter, 'settings.attributes');
        $positive = Arr::get($filter, 'positive');

        if ($filter_type !== 'scope' && is_array($arguments)) {
            array_unshift($arguments, '');
        }

        $query->where(function ($query) use ($filter_type, $attributes, $method, $arguments, $positive) {
            $count = 0;
            foreach ($attributes as $attribute_name) {
                // Place attribute name into argument.
                if ($filter_type !== 'scope' && is_array($arguments)) {
                    $arguments[0] = $attribute_name;

                // Argument is raw and using sprintf.
                } elseif (!is_array($arguments)) {
                    $arguments = [sprintf($arguments, self::quoteIdentifier($attribute_name))];
                }

                if ($filter_type === 'scope') {
                    $arguments[] = $positive;
                }

                $query->$method(...$arguments);

                // Apply an or to the where.
                if ($filter_type !== 'scope' && $count === 0 && $positive) {
                    $method = 'or'.Str::studly($method);
                }

                $count++;
            }
        });
    }
207631
protected function applyFiltersFromModel()
    {
        /*
         * Standard usage
         */
        if (method_exists($this->model, 'filterFields')) {
            $this->model->filterFields((object) $this->allFields, $this->getContext());
        }

        /*
         * Advanced usage
         */
        if (method_exists($this->model, 'fireEvent')) {
            /**
             * @event model.form.filterFields
             * Called after the form is initialized
             *
             * Example usage:
             *
             *     $model->bindEvent('model.form.filterFields', function ((\Backend\Widgets\Form) $formWidget, (stdClass) $fields, (string) $context) use (\October\Rain\Database\Model $model) {
             *         if ($model->source_type == 'http') {
             *             $fields->source_url->hidden = false;
             *             $fields->git_branch->hidden = true;
             *         } elseif ($model->source_type == 'git') {
             *             $fields->source_url->hidden = false;
             *             $fields->git_branch->hidden = false;
             *         } else {
             *             $fields->source_url->hidden = true;
             *             $fields->git_branch->hidden = true;
             *         }
             *     });
             *
             */
            $this->model->fireEvent('model.form.filterFields', [$this, (object) $this->allFields, $this->getContext()]);
        }
    }
283197
protected function _prepare_filter() {
		$term = \get_queried_object();

		if ( ! empty( $term->slug ) && ! empty( $term->taxonomy ) ) {
			$this->term     = $term->slug;
			$this->taxonomy = $term->taxonomy;
		}
	}
521400
public function apply()
    {
        if ( method_exists( $this->view, 'plugin' ) )
        {
            $global     = false;
            $roots      = (array) $this->roots;
            $headLink   = $this->getHeadLinkHelper();

            if ( in_array( null, $roots ) )
            {
                $global = true;
            }

            $roots = array_filter( $roots );

            if ( $global )
            {
                $roots[] = null;
            }

            $find       = array();
            $urls       = array();
            $preview    = false;

            foreach ( $roots as $root )
            {
                if ( $this->cssPreview->hasPreviewById( $root ) )
                {
                    $urls[$root] = $this->cssPreview
                                        ->getPreviewById( $root );
                }

                if ( empty( $urls[$root] ) )
                {
                    $find[] = $root;
                }
                else
                {
                    $preview = true;
                }
            }

            if ( ! empty( $find ) )
            {
                $url        = $this->getUrlHelper();
                $siteInfo   = $this->getSiteInfo();
                $schema     = $siteInfo->getSchema();
                $updated    = $this->extraModel
                                   ->findUpdated( $find );

                foreach ( $find as $root )
                {
                    if ( isset( $updated[$root] ) )
                    {
                        $urls[$root] = $url( 'Grid\Customize\Render\CustomCss', array(
                            'schema'    => $schema,
                            'id'        => $root ? (int) $root : 'global',
                            'hash'      => $updated[$root]->toHash(),
                        ) );
                    }
                }
            }

            foreach ( $roots as $root )
            {
                if ( ! empty( $urls[$root] ) )
                {
                    $id = $root ? (int) $root : 'global';

                    $headLink->prependStylesheet(
                        $urls[$root],
                        'all',
                        false,
                        array(
                            'class'             => 'customize-stylesheet',
                            'data-customize'    => $id,
                        )
                    );
                }
            }

            if ( $preview )
            {
                if ( empty( $url ) )
                {
                    $url = $this->getUrlHelper();
                }

                $translate = $this->getTranslateHelper();

                $this->getMessengerHelper()
                     ->add(
                         sprintf(
                             $translate(
                                 'customize.preview.applied.reset-link.%s',
                                 'customize'
                             ),
                             $url( 'Grid\Customize\CssAdmin\ResetPreviews', array(
                                 'locale' => \Locale::getDefault(),
                             ) )
                         ),
                         false,
                         Message::LEVEL_WARN
                     );
            }

            $this->roots = array();
        }

        return $this;
    }
1033512
public function apply()
    {
        if ($this->canApply()) {
            $before = self::cloneNodeWithNodeData($this->getSubject());
            $parent = $before->getParent();

            if ($this->nodeNameAvailableBelowNode($this->getSiblingNode()->getParent(), $this->getSubject())) {
                $this->getSubject()->moveAfter($this->getSiblingNode());
            } else {
                $nodeName = $this->generateUniqueNodeName($this->getSiblingNode()->getParent());
                $this->getSubject()->moveAfter($this->getSiblingNode(), $nodeName);
            }

            $updateParentNodeInfo = new UpdateNodeInfo();
            $updateParentNodeInfo->setNode($parent);

            $this->feedbackCollection->add($updateParentNodeInfo);

            $this->finish($before);
        }
    }
181535
public function addFilters()
    {
        foreach (func_get_args() as $filter) {
            if (is_a($filter, 'Rhubarb\Stem\Filters\Filter')) {
                $this->filters[] = $filter;
            } else {
                throw new \Exception('Non filter object added to Group filter');
            }
        }
    }
895158
private function runFilters()
    {
        foreach ($this->filterObjects as $filter) {
            $filter_key = $filter->getKey();

            // Execute the filter method if enabled
            if ($this->request->has($filter_key)) {
                $filter_option = ucfirst(preg_replace('/[^a-z0-9]/i', ' ', $this->request->input($filter_key)));

                $filter_key = ucfirst(preg_replace('/[^a-z0-9]/i', ' ', $filter_key));

                if (!in_array($filter_option, $this->filters[$filter_key])) {
                    continue;
                }

                $filter_method = 'filter'.Str::studly($filter_key).Str::studly($filter_option);

                if (method_exists($this, $filter_method)) {
                    $this->$filter_method();
                }
            }
        }
    }
1031202
private function applyFilters()
    {
        $layer      = $this->layerResolver->get();
        $filterList = $this->getFilterList();

        foreach ($filterList->getFilters($layer) as $filter) {
            $filter->apply($this->getRequest());
        }

        $layer->apply();

        return $this;
    }
662317
public function onFilterUpdate()
    {
        $this->defineFilterScopes();

        if (!$scope = post('scopeName')) {
            return;
        }

        $scope = $this->getScope($scope);

        switch ($scope->type) {
            case 'group':
                $active = $this->optionsFromAjax(post('options.active'));
                $this->setScopeValue($scope, $active);
                break;

            case 'checkbox':
                $checked = post('value') == 'true';
                $this->setScopeValue($scope, $checked);
                break;

            case 'switch':
                $value = post('value');
                $this->setScopeValue($scope, $value);
                break;

            case 'date':
                $dates = $this->datesFromAjax(post('options.dates'));

                if (!empty($dates)) {
                    list($date) = $dates;
                }
                else {
                    $date = null;
                }

                $this->setScopeValue($scope, $date);
                break;

            case 'daterange':
                $dates = $this->datesFromAjax(post('options.dates'));

                if (!empty($dates)) {
                    list($after, $before) = $dates;

                    $dates = [$after, $before];
                }
                else {
                    $dates = null;
                }

                $this->setScopeValue($scope, $dates);
                break;

            case 'number':
                $numbers = $this->numbersFromAjax(post('options.numbers'));

                if (!empty($numbers)) {
                    list($number) = $numbers;
                }
                else {
                    $number = null;
                }

                $this->setScopeValue($scope, $number);
                break;

            case 'numberrange':
                $numbers = $this->numbersFromAjax(post('options.numbers'));

                if (!empty($numbers)) {
                    list($min, $max) = $numbers;

                    $numbers = [$min, $max];
                }
                else {
                    $numbers = null;
                }

                $this->setScopeValue($scope, $numbers);
                break;

            case 'text':
                $values = post('options.value');

                if ($values !== null && $values !== '') {
                    list($value) = $values;
                }
                else {
                    $value = null;
                }

                $this->setScopeValue($scope, $value);
                break;
        }

        /*
         * Trigger class event, merge results as viewable array
         */
        $params = func_get_args();

        $result = $this->fireEvent('filter.update', [$params]);

        if ($result && is_array($result)) {
            return call_user_func_array('array_merge', $result);
        }
    }
1061639
public function sanitize()
    {
        if (method_exists($this, 'filters')) {
            $filtry = \Filtry::make($this->all(), $this->filters());
            $this->merge($filtry->getFiltered());
        }
    }
541264
public function initialize()
    {
        if (empty($this->columnFilters)) {
            return;
        }

        $this->validNumberOfFilters();

        foreach ($this->all() as $filter) {
            if ($filter instanceof Initializable) {
                $filter->initialize();
            }
        }

        $this->validNumberOfFilters();

        $filters = collect($this->columnFilters);

        if ($filters->last() === null) {
            $filters->pop();
            $filters->push(new Control());
        }

        $this->columnFilters = $filters;

        $this->prepareView();
    }
878593
protected function filter()
    {
        $lists = [
            'listCompetitions',
            'listCountries',
            'listEvents',
            'listEventTypes',
            'listMarketTypes',
            'listVenues',
            'listMarketCatalogue'
        ];

        if (in_array($this->method, $lists) && empty($this->params[ 'filter' ])) {
            $this->params[ 'filter' ] = new \stdClass;
        }
    }
799554
public function search()
    {
        $this->load($this->params, '');
        $query = $this->getBasicQuery();
        $languageId = Language::getCurrent()->id;
        $category = Category::findOne($this->categoryId);

        if(!empty($this->filterModel) && $this->filterModel instanceof FilterModel) {
            if(!empty($this->filterModel->pfrom) && $this->filterModel->pfrom != $this->filterModel->minPrice) {
                $query->andWhere(['>=', $this->discountPriceQuery, $this->convertPrice($this->filterModel->pfrom)]);
            }
            if(!empty($this->filterModel->pto) && $this->filterModel->pto != $this->filterModel->maxPrice) {
                $query->andWhere(['<=', $this->discountPriceQuery, $this->convertPrice($this->filterModel->pto)]);
            }
            if(!empty($this->filterModel->vendors)) {
                $query->andWhere(['in', 'shop_product.vendor_id', $this->filterModel->vendors]);
            }
            if(!empty($this->filterModel->availabilities)) {
                $query->andWhere(['in', 'shop_product.availability', $this->filterModel->availabilities]);
            }

            if(!empty($this->filterModel->params)) {
                foreach ($category->filter->params as $filterParam) {
                    if(array_key_exists($filterParam->key, $this->filterModel->params)) {
                        $paramValues = $this->filterModel->params[$filterParam->key];
                        if(!empty($paramValues)) {
                            $key = $filterParam->key;
                            $paramName = $filterParam->translation->param_name;
                            $query->leftJoin("shop_param param_$key", "shop_product.id = param_$key.product_id");
                            $query->leftJoin("shop_param_translation paramt_$key", "param_$key.id = paramt_$key.param_id AND paramt_$key.language_id = $languageId AND paramt_$key.name = '$paramName'");
                            $whereQuery = ['or'];
                            for ($i = 0; $i < count($paramValues); $i++) {
                                $paramValue = $paramValues[$i];
                                $whereQuery[] = ['or',
                                    ["paramt_$key.value" => $paramValue],
                                    new Expression("FIND_IN_SET(:param$i" . "Value1_$key, paramt_$key.value)", [":param$i" . "Value1_$key" => $paramValue]),
                                    new Expression("FIND_IN_SET(:param$i" . "Value2_$key, paramt_$key.value)", [":param$i" . "Value2_$key" => " " . $paramValue])
                                ];
                            }
                            $query->andWhere($whereQuery);
                        }
                    }
                }
            }
        }


        switch (ArrayHelper::getValue($this->params, 'sort')) {
            case self::SORT_CHEAP:
                $query->select([
                    '`shop_product`.*',
                    $this->discountPriceQuery . ' AS discount_price'
                ]);

                $query->orderBy(['discount_price' => SORT_ASC]);
                break;

            case self::SORT_EXPENSIVE:
                $query->select([
                    '`shop_product`.*',
                    $this->discountPriceQuery . ' AS discount_price'
                ]);

                $query->orderBy(['discount_price' => SORT_DESC]);
                break;

            case self::SORT_OLD:
                $query->orderBy(['creation_time' => SORT_ASC]);
                break;

            case self::SORT_NEW:
                $query->orderBy(['creation_time' => SORT_DESC]);
                break;

            default:
                $query->orderBy(['category_id' => SORT_ASC, 'position' => SORT_ASC]);
        }

        $query->groupBy(['id']);

        $dataProvider = new ActiveDataProvider([
            'query' => $query
        ]);

        if ($this->validate()) {
            return $dataProvider;
        }
        else throw new Exception();
    }
107927
private function applyFilters()
    {
        $availableOptions = ['name', 'method', 'uri', 'action', 'middleware'];
        foreach ($this->options() as $key => $option) {
            if (in_array($key, $availableOptions) && null != $option) {
                foreach ($this->routes as $index => $route) {
                    if (!str_contains(strtolower($route[$key]), strtolower($option)))
                        unset($this->routes[$index]);
                }
            }
        }
    }
1052633
public function apply()
    {
        if ($this->canApply()) {
            $nodeName = $this->generateUniqueNodeName($this->getParentNode());
            $node = $this->getSubject()->copyInto($this->getParentNode(), $nodeName);
            $this->finish($node);
        }
    }
1009192
private function applyFilters(array $settings): void
    {
        foreach ($settings as $column => $filters) {
            foreach ($filters as $filter => $value) {
                if ($filter === Grid\Grid::FILTER_LIKE) {
                    $value = '%' . $value . '%';
                }
                $this->getSource()->andWhere($column . ' ' . $this->filters[$filter] . ' ?', $value);
            }
        }
    }
595253
protected function filters()
    {
        $where = $this->initFilters();

        $gf = $this->globalFilter();
        $where .= (empty($where) ? $gf : (empty($gf) ? '' : ' AND '.$gf));

        $gf = $this->individualColumnFilters();
        $where .= (empty($where) ? $gf : (empty($gf) ? '' : ' AND '.$gf));

        return $where;
    }