@param bool $new

@return WhereBuilder
326167
public function getWhereBuilder($new = false)
    {
        if ($new) {
            return new WhereBuilder();
        }

        if (null == self::$whereBuilder) {
            $this->resetWhereBuilder();
        }

        return self::$whereBuilder;
    }
129778
public function andWhere($bool = "must", array $params = []) {
        $callback = function(SubQueryBuilder $subQuery) use ($bool, $params) {
            return $this->_endChildSubQuery("and", $subQuery->toArray(), $bool, $params);
        };
        return SubQueryBuilder::make($callback);
    }
735929
private function buildWhereForUpdate()
    {
        $whereArray = array_combine($this->where, $this->bindings);
        list($whereNew, $condition) = $this->formatWhereToNamePlaceHolder($whereArray);

        return [$whereNew, $this->buildWherePlaceholderName($whereNew)];
    }
232348
public function where($condition) 
    {       
        $this->condition = $condition;
        $this->sql .= ' WHERE ' . $this->buildCondition($condition);
        
        return $this;
    }
439913
public function getWriter($new = true)
    {
        if (!$this->writer || $new) {
            $class = sprintf('Windwalker\\Database\\Driver\\%s\\%sWriter', ucfirst($this->name), ucfirst($this->name));

            $this->writer = new $class($this);
        }

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

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

        return $this;
    }
179226
public function andWhere($void = null)
    {
        $this->ensureNoArguments(__METHOD__, $void);

        return $this->addChild(new WhereAnd($this));
    }
1080290
public function newQuery($excludeDeleted = true) {
    $builder = parent::newQuery($excludeDeleted);
    $builder->where(static::$table_type_field, '=', $this->table_type);

    return $builder;
  }
366082
public function addNestedWhereQuery($query, $boolean = 'and')
    {
        if (count($query->wheres)) {
            $type = 'Nested';
            $column = null;
            $value = $query->wheres;
            $this->wheres[] = compact('column', 'type', 'value', 'boolean');
        }

        return $this;
    }
712252
public function newQuery($excludeDeleted = true)
	{
		$builder = $this->newActiveRecordBuilder($this->newBaseQueryBuilder());

		// Once we have the query builders, we will set the model instances so the
		// builder can easily access any information it may need from the model
		// while it is constructing and executing various queries against it.
		$builder->setModel($this)->with($this->with);

		if ($excludeDeleted && $this->softDelete)
		{
			$builder->whereNull($this->getQualifiedDeletedAtColumn());
		}

		return $builder;
	}
565916
private function getMeta($create = false)
    {
        $locale = $this->locale;
        $metaCollection = $this->getFileVersion()->getMeta();

        // get meta only with this locale
        $metaCollectionFiltered = $metaCollection->filter(function($meta) use ($locale) {
            /** @var FileVersionMeta $meta */
            if ($meta->getLocale() == $locale) {
                return true;
            }

            return false;
        });

        // check if meta was found
        if ($metaCollectionFiltered->isEmpty()) {
            if ($create) {
                // create when not found
                $meta = new FileVersionMeta();
                $meta->setLocale($this->locale);
                $meta->setFileVersion($this->getFileVersion());
                $this->getFileVersion()->addMeta($meta);

                return $meta;
            }

            // return first when create false
            return $this->getFileVersion()->getDefaultMeta();
        }

        // return exists
        return $metaCollectionFiltered->first();
    }
289950
public function getEngine($new = false)
    {
        if (!$this->engine || $new) {
            $this->engine = new PlatesEngine(
                dirname($this->config->get('path.found')),
                ltrim($this->config->get('extension', '.tpl'), '.')
            );

            foreach ($this->folders as $namespace => $folder) {
                $this->engine->addFolder($namespace, $folder['folder'], $folder['fallback']);
            }

            foreach ($this->extensions as $extension) {
                $this->engine->loadExtension($extension);
            }
        }

        return $this->engine;
    }
360451
public function getEngine($new = false)
    {
        if (!$this->engine || $new) {
            $this->engine = new \Mustache_Engine($this->config->get('options', []));
        }

        return $this->engine;
    }
1101046
public function orWhere($void = null)
    {
        $this->ensureNoArguments(__METHOD__, $void);

        return $this->addChild(new WhereOr($this));
    }
1170680
public function whereRaw($sql, array $bindings = array(), $boolean = 'and')
	{
		$type = 'raw';

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

		$this->bindings = array_merge($this->bindings, $bindings);

		return $this;
	}
893546
protected function newQuery($insert = false)
    {
        $query = $this->model->newQuery();

        if ( ! $insert) {
            foreach ($this->extraColumns as $key => $value) {
                $query->where($key, '=', $value);
            }
        }

        if ($this->hasQueryConstraint()) {
            $callback = $this->queryConstraint;
            $callback($query, $insert);
        }

        return $query;
    }
972048
public function whereBool($key = null, $value)
    {
        if (is_bool($value)) {
            $this->where($key, '==', $value);
        }
        return $this;
    }