Compile query builder where clause depending on configurations.

@param mixed  $query
@param string $column
@param string $keyword
@param string $boolean
339350
protected function compileQuerySearch($query, $column, $keyword, $boolean = 'or')
    {
        $column = $this->addTablePrefix($query, $column);
        $column = $this->castColumn($column);
        $sql    = $column . ' LIKE ?';

        if ($this->config->isCaseInsensitive()) {
            $sql = 'LOWER(' . $column . ') LIKE ?';
        }

        $query->{$boolean . 'WhereRaw'}($sql, [$this->prepareKeyword($keyword)]);
    }
333691
protected static function applyFilter($query, $column, $searchValue)
    {
        if ($methodName = self::hasCustomSearch($column)) {
            return self::$class::$methodName($query, $searchValue);
        }

        if (isRelationColumn($column)) {
            return self::applyRelationFilter($query, $column, $searchValue);
        }

        $searchValue = '%'.$searchValue.'%';

        return $query->orWhere($column, 'like', "$searchValue");
    }
783052
public function wherePivot($column, $operator = null, $value = null, $boolean = 'and')
    {
        return $this->where($this->table.'.'.$column, $operator, $value, $boolean);
    }
871335
public function whereIn($column, $values, $boolean = 'and', $not = false)
	{
		$type = $not ? 'NotIn' : 'In';

		// If the value of the where in clause is actually a Closure, we will assume that
		// the developer is using a full sub-select for this "in" statement, and will
		// execute those Closures, then we can re-construct the entire sub-selects.
		if ($values instanceof Closure)
		{
			return $this->whereInSub($column, $values, $boolean, $not);
		}

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

		$this->addBinding($values, 'where');

		return $this;
	}
520345
public function whereIn($column, array $range, $boolean = 'and')
    {
        if (count($range) == 0) {
            throw new QueryBuilderException(
                'Parameter 2 must be contains two values',
                E_ERROR
            );
        }

        $map = array_map(function () {
            return '?';
        }, $range);

        $this->where_data_binding = array_merge($range, $this->where_data_binding);

        $in = implode(', ', $map);

        if (is_null($this->where)) {
            if ($boolean == 'not') {
                $this->where = '(`' . $column . '` not in ('.$in.'))';
            } else {
                $this->where = '(`' . $column .'` in ('.$in.'))';
            }
        } else {
            if ($boolean == 'not') {
                $this->where .= ' and (`' . $column . '` not in ('.$in.'))';
            } else {
                $this->where .= ' and (`'.$column.'` in ('.$in.'))';
            }
        }

        return $this;
    }
1362674
public function where($column, $operator = '=', $value = false, $condition = 'AND')
    {
        $where = array();

        // Raw Query
        if ($column instanceof Raw) {
            $where['raw'] = true;
            $where['query'] = $column->getString();
            $where['condition'] = $condition;
            $where['operator'] = $operator;

            $this->queryCompiler->getQuery()->where($where);

            return $this;
        }

        $where['column'] = $column;
        $where['operator'] = $operator;
        $where['value'] = $this->quote($value);
        $where['condition'] = $condition;

        $this->queryCompiler->getQuery()->where($where);

        return $this;
    }
910183
public function scopeSearch($query, $keyword)
    {
        $columns = $this->searchColumns();

        foreach ($columns as $column) {

            if ($columns === reset($columns)) {

                $query->where($column, 'like', "%{$keyword}%");

            }

            $query->orWhere($column, 'like', "%{$keyword}%");
        }

        return $query;
    }
660817
protected function createSearchClause(Builder $query, $param, $column, $value, $boolean = 'and')
    {
        if ($param === 'query') {
            $query->where($this->appendTableName($column), self::$searchOperator, '%' . $value . '%', $boolean);
        }
        elseif (is_array($value)) {
            $query->whereIn($this->appendTableName($column), $value, $boolean);
        }
        else {
            $query->where($this->appendTableName($column), '=', $value, $boolean);
        }
    }
736255
public function compileUpdate(Builder $query, $values)
    {
        $table = $this->wrapTable($query->from);

        // Each one of the columns in the update statements needs to be wrapped in the
        // keyword identifiers, also a place-holder needs to be created for each of
        // the values in the list of bindings so we can make the sets statements.
        $columns = collect($values)->map(function ($value, $key) {
            return $this->wrap($key).' = '.$this->parameter($value);
        })->implode(', ');

        // If the query has any "join" clauses, we will setup the joins on the builder
        // and compile them so we can attach them to this update, as update queries
        // can get join statements to attach to other tables when they're needed.
        $joins = '';

        if (isset($query->joins)) {
            $joins = ' '.$this->compileJoins($query, $query->joins);
        }

        // Of course, update queries may also be constrained by where clauses so we'll
        // need to compile the where clauses and attach it to the query so only the
        // intended records are updated by the SQL statements we generate to run.
        $wheres = $this->compileWheres($query);

        return trim("update {$table}{$joins} set $columns $wheres");
    }
168058
protected function compileColumnQuery($query, $method, $parameters, $column, $keyword)
    {
        if (method_exists($query, $method) && count($parameters) <= with(new \ReflectionMethod($query, $method))->getNumberOfParameters()
        ) {
            if (Str::contains(Str::lower($method), 'raw') || Str::contains(Str::lower($method), 'exists')
            ) {
                call_user_func_array(
                        [$query, $method], $this->parameterize($parameters, $keyword)
                );
            } else {
                call_user_func_array(
                        [$query, $method], $this->parameterize($column, $parameters, $keyword)
                );
            }
        }
    }
207828
public function whereBetween($column, array $values, $boolean = 'and', $not = false)
    {
        $type = 'between';

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

        $this->addBinding($this->cleanBindings($values), 'where');

        return $this;
    }
145775
public function where( $column, $operator = null, $value = null, $boolean = 'and' )
	{
		if ( $column instanceof Closure )
		{
			$query = $this->model->newQueryWithoutScopes();
			call_user_func( $column, $query );
			$this->query->addNestedWhereQuery( $query->getQuery(), $boolean );
		}
		else
			call_user_func_array( [$this->query, 'where'], func_get_args() );

		return $this;
	}
1337658
public function whereNull($column, $boolean = 'and', $not = false)
    {
        $type = $not ? ComparisonOperator::NOT_NULL : ComparisonOperator::NULL;

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

        return $this;
    }
1134404
public function where($column, $comp = '=', $value = null, $boolean = 'and')
    {
        if (!static::isComporaisonOperator($comp) || is_null($value)) {
            $value = $comp;

            $comp = '=';
        }

        if ($value === null) {
            throw new QueryBuilderException('Valeur de comparaison non définie', E_ERROR);
        }

        if (!in_array(Str::lower($boolean), ['and', 'or'])) {
            throw new QueryBuilderException(
                'Le booléen '. $boolean . ' non accepté',
                E_ERROR
            );
        }

        $this->where_data_binding[$column] = $value;

        if ($this->where == null) {
            $this->where = '('. $column . ' ' . $comp . ' :' . $column . ')';
        } else {
            $this->where .= ' ' . $boolean . ' ('. $column . ' '. $comp .' :'. $column. ')';
        }

        return $this;
    }
962550
protected function whereInExistingQuery($column, $query, $boolean, $not)
    {
        $type = $not ? 'NotInSub' : 'InSub';

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

        $this->addBinding($query->getBindings(), 'where');

        return $this;
    }
1347798
public function scopeKeywords($query, $keyword)
    {
        return $query->where(function ($query) use ($keyword) {
            $query->where('name', 'LIKE', "%$keyword%")
            ->orWhere('description', 'LIKE', "%$keyword%");
        });
    }
1095320
public function compileUpdate(Builder $query, $values)
    {
        [$table, $alias] = $this->parseUpdateTable($query->from);

        // Each one of the columns in the update statements needs to be wrapped in the
        // keyword identifiers, also a place-holder needs to be created for each of
        // the values in the list of bindings so we can make the sets statements.
        $columns = collect($values)->map(function ($value, $key) {
            return $this->wrap($key).' = '.$this->parameter($value);
        })->implode(', ');

        // If the query has any "join" clauses, we will setup the joins on the builder
        // and compile them so we can attach them to this update, as update queries
        // can get join statements to attach to other tables when they're needed.
        $joins = '';

        if (isset($query->joins)) {
            $joins = ' '.$this->compileJoins($query, $query->joins);
        }

        // Of course, update queries may also be constrained by where clauses so we'll
        // need to compile the where clauses and attach it to the query so only the
        // intended records are updated by the SQL statements we generate to run.
        $where = $this->compileWheres($query);

        if (! empty($joins)) {
            return trim("update {$alias} set {$columns} from {$table}{$joins} {$where}");
        }

        return trim("update {$table}{$joins} set $columns $where");
    }