Add an external sub-select to the query.

@param  string   $column
@param  \Illuminate\Database\Query\Builder|static  $query
@param  string   $boolean
@param  bool     $not
@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;
    }
231950
public function orNotBetween($column, $left, $right)
    {
        $this->conditions[] = 'OR ' . $this->grammar->buildId($column) . ' NOT BETWEEN ' . $left . ' AND ' . $right;

        return $this;
    }
1111348
protected function applySearchToQuery($query, $columns, $boolean = 'and')
    {
        $term = $this->searchTerm;

        if ($scopeMethod = $this->searchScope) {
            $searchMethod = $boolean == 'and' ? 'where' : 'orWhere';
            $query->$searchMethod(function ($q) use ($term, $columns, $scopeMethod) {
                $q->$scopeMethod($term, $columns);
            });
        }
        else {
            $searchMethod = $boolean == 'and' ? 'searchWhere' : 'orSearchWhere';
            $query->$searchMethod($term, $columns, $this->searchMode);
        }
    }
56738
public function whereCarried($column, $operator = null, $value = null, $boolean = 'and')
    {
        $type = 'Carried';

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

        return $this;
    }
252737
public function andNotIn($column, $argument)
    {
        $this->conditions[] = 'AND ' . $this->grammar->buildId($column) . ' NOT IN(' . $argument . ')';

        return $this;
    }
1251671
public function addColumn($column)
    {
        if ($column instanceof Element) {
            if ($column->entity->getEntityName() === '') {
                $column->entity->setEntityName('col-' . ($this->childNodes->count() + 1));
            }

            $this->pushColumnChildNodes($column);
        }

        return $this;
    }
1124389
private function buildSubclauseWithNull($subclause, Builder $query, $isNotNull = false)
    {
        if ($isNotNull === true) {
            return $query->whereNotNull($subclause['to_value_column']);
        }

        return $query->whereNull($subclause['to_value_column']);
    }
1097233
public function addNotInCondition($column, $values, $link = 'AND') {
        $this->conditionColumns[] = $column;
        $vals = array();
        foreach ($values as $val) {
            $vals[] = $this->_param($column, $val, true);
        }
        return $this->addCondition($this->_column($column) . ' NOT IN (' . implode(', ', $vals) .' )', array(), $link);
    }
385548
public function on($first, $operator, $second, $boolean = 'and', $where = false)
	{
		$this->clauses[] = compact('first', 'operator', 'second', 'boolean', 'where');

		if ($where) $this->query->addBinding($second);

		return $this;
	}
493432
public function areNull(array $columns, $logicalAnd = true) {
        foreach ($columns as $column) {
            $this->isNull($column, $logicalAnd);
        }
        return $this;
    }
1366140
public function where($field, $value, $not = false)
    {
        $reserverd_word = $this->with_where ? 'AND' : 'WHERE';
        $operator = $not ? '!=' : '=';
        $this->query .= "{$reserverd_word} {$field} {$operator} '{$value}'";
        $this->with_where = true;

        return $this;
    }
185109
public function selectFrom($table, string $column, string ...$columns)
    {
        $instance = $this->selectQueryInstance();

        $instance->selectQuery()->columnsFrom($table, $column, ...$columns);

        return $instance;
    }
1055581
public function select(string $column, string ...$columns)
    {
        $instance = $this->selectQueryInstance();

        $instance->selectQuery()->columns($column, ...$columns);

        return $instance;
    }
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;
	}
453994
public function whereIn($column, $values, $boolean = 'and', $not = false)
    {
        $type = $not ? 'NotIn' : 'In';

        // If the value is a query builder instance we will assume the developer wants to
        // look for any values that exists within this given query. So we will add the
        // query accordingly so that this query is properly executed when it is run.
        if ($values instanceof static) {
            return $this->whereInExistingQuery(
                $column,
                $values,
                $boolean,
                $not
            );
        }

        // 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);
        }

        // Next, if the value is Arrayable we need to cast it to its raw array form so we
        // have the underlying array value instead of an Arrayable object which is not
        // able to be added as a binding, etc. We will then add to the wheres array.
        if ($values instanceof Arrayable) {
            $values = $values->toArray();
        }

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

        // Finally we'll add a binding for each values unless that value is an expression
        // in which case we will just skip over it since it will be the query as a raw
        // string and not as a parameterized place-holder to be replaced by the PDO.
        foreach ($values as $value) {
            if (!$value instanceof Expression) {
                $this->addBinding($value, 'where');
            }
        }

        return $this;
    }
671228
public static function where($column, $operator = null, $value = null, $boolean = 'and')
    {
        if ($boolean !== 'and') {
            throw new NotSupportedException('Only support "and" in where clause');
        }
        $model = static::getInstance();
        // 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)) {
            foreach ($column as $key => $value) {
                $model->addWhere($key, '=', $value, $boolean);
            }

            return $model;
        }

        $model->addWhere($column, $operator, $value, $boolean);

        return $model;
    }
1229255
protected function whereSub($column, $operator, Closure $callback, $boolean)
    {
        $type = 'Sub';

        $query = $this->newQuery();

        // Once we have the query instance we can simply execute it so it can add all
        // of the sub-select's conditions to itself, and then we can cache it off
        // in the array of where clauses for the "main" parent query instance.
        call_user_func($callback, $query);

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

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

        return $this;
    }