Where query matches field

@param  string $field
@param  string $query
@param  string $operator
@param  int    $fuzziness
@return $this
770208
public function whereMatch(string $field, string $query, $operator = "or", $fuzziness = 0)
    {
        $param = [
            "match" => [
                $field => [
                    "query" => $query,
                    "operator" => $operator,
                    "fuzziness" => $fuzziness
                ]
            ]
        ];

        $this->elasticQuery[] = $param;
        return $this;
    }
571950
private function applyWhereClause(Builder $query, $field, $operator, $value, $or = false) {
        $verb = $or ? 'orWhere' : 'where';
        $null_verb = $or ? 'orWhereNull' : 'whereNull';
        $not_null_verb = $or ? 'orWhereNotNull' : 'whereNotNull';

        $value = $this->base64decodeIfNecessary($value);

        switch ($value) {
            case 'today':
                return $query->$verb($field, 'like', Carbon::now()->format('Y-m-d') . '%');
            case 'nottoday':
                return $query->$verb(function ($q) use ($field) {
                    $q->where($field, 'not like', Carbon::now()->format('Y-m-d') . '%')
                        ->orWhereNull($field);
                });
            case 'null':
                return $query->$null_verb($field);
            case 'notnull':
                return $query->$not_null_verb($field);
            default:
                return $query->$verb($field, $operator, $value);
        }
    }
749964
public function where($field, $operator, $value = null)
    {
        if (is_null($value)) {
            $value    = $operator;
            $operator = '=';
        }

        return $this->filter(function ($data) use ($field, $operator, $value) {
            if (strpos($field, '.')) {
                list($field, $relation) = explode('.', $field);

                $result = isset($data[$field][$relation]) ? $data[$field][$relation] : null;
            } else {
                $result = isset($data[$field]) ? $data[$field] : null;
            }

            switch ($operator) {
                case '===':
                    return $result === $value;
                case '!==':
                    return $result !== $value;
                case '!=':
                case '<>':
                    return $result != $value;
                case '>':
                    return $result > $value;
                case '>=':
                    return $result >= $value;
                case '<':
                    return $result < $value;
                case '<=':
                    return $result <= $value;
                case 'like':
                    return is_string($result) && false !== strpos($result, $value);
                case 'not like':
                    return is_string($result) && false === strpos($result, $value);
                case 'in':
                    return is_scalar($result) && in_array($result, $value, true);
                case 'not in':
                    return is_scalar($result) && !in_array($result, $value, true);
                case 'between':
                    list($min, $max) = is_string($value) ? explode(',', $value) : $value;
                    return is_scalar($result) && $result >= $min && $result <= $max;
                case 'not between':
                    list($min, $max) = is_string($value) ? explode(',', $value) : $value;
                    return is_scalar($result) && $result > $max || $result < $min;
                case '==':
                case '=':
                default:
                    return $result == $value;
            }
        });
    }
882326
public function whereArr($data, $operator = '=')
    {
        foreach ($data as $key => $value) {
            $this->where($key, $value, $operator);
        }

        return $this;
    }
32007
public function orWhere(string $key, string $operator, $value): QueryBuilder
    {
        $this->addWhere($key, $operator, $value, 'OR');
        return $this;
    }
1179727
public function where(string $key, string $operator, $value): QueryBuilder
    {
        $this->addWhere($key, $operator, $value, 'AND');
        return $this;
    }
662205
public function whereOr($field, $op = null, $condition = null) {
        $this->addWhere("OR", $field, $op, $condition);
        return $this;
    }
1015805
public static function fuzzy($field, $value, $fuzziness = 'AUTO')
    {
        $body = array(
            'query' => array(
                'fuzzy' => array(
                    $field => array(
                        'value' => $value,
                        'fuzziness' => $fuzziness
                    )
                )
            ),
            'size' => 1000
        );

        return static::search($body);
    }
1085070
public function where($column, $operator, $value = null)
    {
        $this->wConditions()->column(...func_get_args());

        return $this;
    }
991309
public function where($column, $operator = null, $value = null, $boolean = 'and')
    {
        // Tratar alias do _id
        $column = ($column == 'id') ? '_id' : $column;

        // Here we will make some assumptions about the operator. If only 2 values are
        // passed to the method, we will assume that the operator is an equals sign
        // and keep going. Otherwise, we'll require the operator to be passed in.
        list($value, $operator) = $this->prepareValueAndOperator(
            $value, $operator, func_num_args() == 2
        );

        // If the columns is actually a Closure instance, we will assume the developer
        // wants to begin a nested where statement which is wrapped in parenthesis.
        // We'll add that Closure to the query then return back out immediately.
        if ($column instanceof Closure) {
            return $this->whereNested($column, $boolean);
        }

        // If the given operator is not found in the list of valid operators we will
        // assume that the developer is just short-cutting the '=' operators and
        // we will set the operators to '=' and set the values appropriately.
        if ($this->invalidOperator($operator)) {
            list($value, $operator) = [$operator, '='];
        }

        // If the value is a Closure, it means the developer is performing an entire
        // sub-select within the query and we will need to compile the sub-select
        // within the where clause to get the appropriate query record results.
        // BRUNO-AKI
        //if ($value instanceof Closure) {
        //    return $this->whereSub($column, $operator, $value, $boolean);
        //}

        // If the value is "null", we will just assume the developer wants to add a
        // where null clause to the query. So, we will allow a short-cut here to
        // that method for convenience so the developer doesn't have to check.
        if (is_null($value)) {
            return $this->whereNull($column, $boolean, $operator !== '=');
        }

        // Now that we are working with just a simple query we can put the elements
        // in our array and add the query binding to our array of bindings that
        // will be bound to each SQL statements when it is finally executed.
        $type = 'Basic';

        $this->wheres[] = compact(
            'type', 'column', 'operator', 'value', 'boolean'
        );

        return $this;
    }
490145
public static function where($column, $operator = null, $value = null, $boolean = 'and')
    {
        return parent::query()->where($column, $operator, $value, $boolean);
    }
926267
public function and(string $field, string $operator, string $field2)
    {
        $this->addClause(
            'where',
            compact('field', 'operator', 'field2')
        );

        return $this;
    }
668538
public function where($key, $operator, $value = null)
    {
        if (func_num_args() == 2) {
            $value = $operator;

            $operator = '=';
        }

        return $this->filter($this->operatorForWhere($key, $operator, $value));
    }
394097
public function addWhere($where, $params = [], $operator = 'AND')
    {
        if ($where instanceof Criteria) {
            return $this->addCriteria($where);
        }
        if (null === $where) {
            return $this;
        }
        if (isset($this->query['where']) && !empty($this->query['where'])) {
            $operator = strtoupper($operator);
            $where = "({$this->query['where']}) {$operator} ({$where})";
        }
        $this->query['where'] = $where;
        $this->addParams($params);
        return $this;
    }
605907
public function addFilter($field, $value, $operator= '=')
    {
        $this->filter[] = [
          'field' => $field,
          'value' => $value,
          'operator' => $operator,
        ];
        
        return $this;
    }
404823
public function where($column, $operator = null, $value = null, $boolean = 'and')
	{
        // First we check whether the operator is 'IN' so that we call whereIn() on it
        // as a helping hand and centralization strategy, whereIn knows what to do with the IN operator.
        if (mb_strtolower($operator) == 'in')
        {
            return $this->whereIn($column, $value, $boolean);
        }

        // If the column is an array, we will assume it is an array of key-value pairs
		// and can add them each as a where clause. We will maintain the boolean we
		// received when the method was called and pass it into the nested where.
		if (is_array($column))
		{
			return $this->whereNested(function(IlluminateQueryBuilder $query) use ($column)
			{
				foreach ($column as $key => $value)
				{
					$query->where($key, '=', $value);
				}
			}, $boolean);
		}

		if (func_num_args() == 2)
		{
			list($value, $operator) = array($operator, '=');
		}
		elseif ($this->invalidOperatorAndValue($operator, $value))
		{
			throw new \InvalidArgumentException("Value must be provided.");
		}

		// If the columns is actually a Closure instance, we will assume the developer
		// wants to begin a nested where statement which is wrapped in parenthesis.
		// We'll add that Closure to the query then return back out immediately.
		if ($column instanceof Closure)
		{
			return $this->whereNested($column, $boolean);
		}

		// If the given operator is not found in the list of valid operators we will
		// assume that the developer is just short-cutting the '=' operators and
		// we will set the operators to '=' and set the values appropriately.
		if ( ! in_array(mb_strtolower($operator), $this->operators, true))
		{
			list($value, $operator) = array($operator, '=');
		}

		// If the value is a Closure, it means the developer is performing an entire
		// sub-select within the query and we will need to compile the sub-select
		// within the where clause to get the appropriate query record results.
		if ($value instanceof Closure)
		{
			return $this->whereSub($column, $operator, $value, $boolean);
		}

		// If the value is "null", we will just assume the developer wants to add a
		// where null clause to the query. So, we will allow a short-cut here to
		// that method for convenience so the developer doesn't have to check.
		if (is_null($value))
		{
			return $this->whereNull($column, $boolean, $operator != '=');
		}

		// Now that we are working with just a simple query we can put the elements
		// in our array and add the query binding to our array of bindings that
		// will be bound to each SQL statements when it is finally executed.
		$type = 'Basic';

        $property = $column;

        // When the column is an id we need to treat it as a graph db id and transform it
        // into the form of id(n) and the typecast the value into int.
        if ($column == 'id')
        {
            $column = 'id('. $this->modelAsNode() .')';
            $value = intval($value);
        }
        // When it's been already passed in the form of NodeLabel.id we'll have to
        // re-format it into id(NodeLabel)
        elseif (preg_match('/^.*\.id$/', $column))
        {
            $parts = explode('.', $column);
            $column = sprintf('%s(%s)', $parts[1], $parts[0]);
            $value = intval($value);
        }
        // Also if the $column is already a form of id(n) we'd have to type-cast the value into int.
        elseif (preg_match('/^id\(.*\)$/', $column)) $value = intval($value);

        $binding = $this->prepareBindingColumn($column);

        $this->wheres[] = compact('type', 'binding', 'column', 'operator', 'value', 'boolean');

        $property = $this->wrap($binding);

        if ( ! $value instanceof Expression)
        {
			$this->addBinding([$property => $value], 'where');
		}

		return $this;
	}
582620
public function whereTerms(string $field, array $query)
    {
        $param = [
            "terms" => [
                $field => $query
            ]
        ];

        $this->elasticQuery[] = $param;
        return $this;
    }