Applies the filter value to the query.

@param Builder $query
@param string  $target
@param mixed   $value
@param array   $parameters
489481
public function apply($query, $target, $value, $parameters = [])
    {
        $this->model      = $query->getModel();
        $this->parameters = $parameters;

        $targets = $this->parseTargets($target);

        // If there is only a single target, do not group the condition.
        if (count($targets) == 1) {

            $this->applyForSingleTarget($query, head($targets), $value, true);

            return;
        }

        // If we combine with the 'or' operator, group the filter's conditions
        // so the relation with the other filters is kept inclusive.

        $query->where(function ($query) use ($targets, $value) {

            $this->combineOr = true;

            foreach ($targets as $index => $singleTarget) {

                $this->applyForSingleTarget($query, $singleTarget, $value, $index < 1);
            }
        });
    }
416102
public function apply(Builder $query, $or = false)
    {
        $field_alias = $this->field_alias;

        if($or)
        {
            $query->orWhereNotBetween($field_alias, [$this->value_min, $this->value_max]);
        }
        else
        {
            $query->whereNotBetween($field_alias, [$this->value_min, $this->value_max]);
        }
    }
45261
public function applyToQueryBuilder(QueryBuilder $qb, &$parameterOffset = 0)
	{
		$expr = $qb->expr();

		$conditions = $this->conditions;
		foreach ($conditions as $condition) {
			$field = $condition[self::FIELD_POS];
			switch ($field) {
				case self::LEFT_FIELD:
				case self::RIGHT_FIELD:
				case self::LEVEL_FIELD:
					break;
				default:
					throw new Exception\InvalidArgument("Field $field is not recognized");
			}

			$where = null;
			$field = "e.$field";
			$parameterIndex = $parameterOffset;
			$parameterOffset++;

			$relation = $condition[self::RELATION_POS];
			$value = $condition[self::VALUE_POS];
			$valueExpr = '?' . $parameterIndex;
			
			switch ($relation) {
				case self::RELATION_EQUALS:
					$where = $expr->eq($field, $valueExpr);
					break;
				case self::RELATION_LESS_OR_EQUALS:
					$where = $expr->lte($field, $valueExpr);
					break;
				case self::RELATION_GREATER_OR_EQUALS:
					$where = $expr->gte($field, $valueExpr);
					break;
				case self::RELATION_LESS:
					$where = $expr->lt($field, $valueExpr);
					break;
				case self::RELATION_GREATER:
					$where = $expr->gt($field, $valueExpr);
					break;
				case self::RELATION_NOT_EQUALS:
					$where = $expr->neq($field, $valueExpr);
					break;
				default:
					throw new Exception\InvalidArgument("Relation $relation is not recognized");
			}

			$qb->andWhere($where)
					->setParameter($parameterIndex, $value);
		}
		
		if ( ! empty($this->additionalCondition)) {
			$qb->andWhere($this->additionalCondition);
		}
	}
264377
public function applyOffsetAndLimit(QueryBuilder $query, ?int $offset, ?int $limit): void
    {
        $query->setFirstResult($offset ?? 0);

        if (is_int($limit) && $limit > 0) {
            $query->setMaxResults($limit);
        }
    }
1245537
public function filterQuery(QueryBuilder &$query, &$selects = null)
    {
        //run the parent method
        parent::filterQuery($query, $selects);

        //if there is no value, return
        if ($this->getFilterValue($this->getOption('value')) === false) {
            return;
        }

        $query->where($this->config->getDataModel()->getTable().'.'.$this->getOption('field_name'), '=', $this->getOption('value'));
    }
64583
protected function filtersExact(Builder $query, $value, string $property)
    {
        $property = self::sanitize($property);

        if (is_array($value)) {
            return $query->whereIn($property, $value);
        }

        if (is_numeric($value)) {
            return $query->where($property, $value);
        }

        return $query->where($property, 'like', "%$value%");
    }
234071
private function applyNestedFilter(Builder $query, array $fields, $operator, $value, $or = false)
    {
        $relation_name = implode('.', array_slice($fields, 0, count($fields) - 1));
        $relation_field = end($fields);
        if ($relation_name[0] == '!') {
            $relation_name = substr($relation_name, 1, strlen($relation_name));

            $that = $this;

            return $query->whereHas($relation_name, function ($query) use ($relation_field, $operator, $value, $that, $or) {
                $query = $that->applyWhereClause($query, $relation_field, $operator, $value, $or);
            }, '=', 0);
        }

        $that = $this;

        return $query->whereHas($relation_name, function ($query) use ($relation_field, $operator, $value, $that, $or) {
            $query = $that->applyWhereClause($query, $relation_field, $operator, $value, $or);
        });
    }
527533
public function where($parameter, $value)
    {
        if (! $this->verify($parameter, $value)) {
            return true;
        }

        $this->search = $this->search
            ->where($parameter, 'LIKE', '%' . $value . '%');
    }
782694
protected function paginateList(Builder $query): void
    {
        $this->setAttribute('list', $query->paginate($this->getAttribute('rowsNumber')));
        $this->getAttribute('list')->appends([
            'rowsNumber' => $this->getAttribute('rowsNumber'),
            'search'     => $this->getAttribute('search'),
            'sortBy'     => $this->getAttribute('sortBy'),
            'sortDir'    => $this->getAttribute('sortDir'),
        ]);
    }
26228
public function apply($builder, QueryInterface $query): void
    {
        // Apply joins
        foreach ($query->getJoins() as $join) {
            if ($join->isInner()) {
                $builder->innerJoin($join->getFromAlias(), $join->getTo(), $join->getToAlias(), $join->getCondition());
            } else {
                $builder->leftJoin($join->getFromAlias(), $join->getTo(), $join->getToAlias(), $join->getCondition());
            }
        }

        // Apply rules
        foreach ($query->getRules() as $rule) {
            $builder->andWhere($rule->getRule());
        }

        // Apply parameters
        foreach ($query->getParameters() as $parameter) {
            $builder->setParameter($parameter->getName(), $parameter->getValue(), $parameter->getType());
        }

        // Apply orders
        foreach ($query->getOrders() as $order) {
            $builder->addOrderBy($order->getField(), $order->getDirection());
        }
    }
1042739
protected function addSelectsToQuery(Builder $query, array $selects)
    {
        if (!empty($selects)) {
            $query->selectRaw('max(' . implode(' + ', $selects) . ') as relevance', $this->searchBindings);
        }
    }
730948
public function apply($name, $value, $query, FilterInterface $filter)
    {
        $column = ( ! empty($this->table) ? $this->table . '.' : null)
                . ( ! empty($this->column) ? $this->column : $name);

        $operator = '=';

        if ( ! $this->exact) {
            $operator = 'LIKE';
            $value    = '%' . $value . '%';
        }

        return $query->where($column, $operator, $value);
    }
319940
private function doGetRequest($target, $parameters)
	{
		// Execute the GET request to the given target, along with the given parameters.
		$guzzle = $this->client->getGuzzle();
		$response = $guzzle->get($target, ['query' => $parameters]);
		return $response;
	}
271307
public function apply(Builder $query, $or = false)
    {
        $field_alias = $this->field_alias;

        if($or)
        {
            $query->orWhere($field_alias, '<', $this->value);
        }
        else
        {
            $query->where($field_alias, '<', $this->value);
        }
    }
862931
public function applySorts(Builder $query, string $alias = null)
    {
        foreach ($this->getSorts() as $sort) {
            $sort->apply($query, $alias);
        }
    }
972324
public function setFilters($filters, QueryBuilder &$query, QueryBuilder &$countQuery, &$selects)
    {
        //then we set the filters
        if ($filters && is_array($filters)) {
            foreach ($filters as $filter) {
                //get the field object
                $fieldObject = $this->fieldFactory->findFilter($filter['field_name']);

                //set the filter on the object
                $fieldObject->setFilter($filter);

                //filter the query objects, only pass in the selects the first time so they aren't added twice
                $fieldObject->filterQuery($query, $selects);
                $fieldObject->filterQuery($countQuery);
            }
        }
    }
482168
public function query(
        Query $query,
        array $parameters = []
    ): Result {
        $resultingItems = $this->items[$this->getIndexKey()] ?? [];

        if (!empty($query->getFilters())) {
            foreach ($query->getFilters() as $filter) {
                if (Filter::TYPE_QUERY === $filter->getFilterType() && $filter->getValues() === ['']) {
                    continue;
                }

                if ('_id' !== $filter->getField()) {
                    throw new LogicException('Queries by field different than UUID not allowed in InMemoryRepository. Only for testing purposes.');
                }

                $resultingItems = [];
                $itemUUIDs = $filter->getValues();
                foreach ($itemUUIDs as $itemUUID) {
                    $resultingItems[$itemUUID] = $this->items[$this->getIndexKey()][$itemUUID] ?? null;
                }
            }
        }

        $resultingItems = array_values(
            array_slice(
                array_filter($resultingItems),
                $query->getFrom(),
                $query->getSize()
            )
        );

        $items = $this->items[$this->getIndexKey()] ?? [];
        $result = new Result($query->getUUID(), count($items), count($resultingItems));
        foreach ($resultingItems as $resultingItem) {
            $result->addItem($resultingItem);
        }

        return $result;
    }