Get new Query.

@param array $ignoreScopes
@return Builder
495489
protected function newQuery($ignoreScopes = [])
    {
        $query = new Builder();
        $query->setModel($this);
        $query->setQuery($this->newQueryNotModel($ignoreScopes));

        return $query;
    }
667505
public function create(ScopeInterface $scope): ScopeInterface
    {
        try {
            $now    = $this->ignoreException(function (): DateTimeImmutable {
                return new DateTimeImmutable();
            });
            $schema = $this->getDatabaseSchema();
            $this->createResource([
                $schema->getScopesIdentityColumn()    => $scope->getIdentifier(),
                $schema->getScopesDescriptionColumn() => $scope->getDescription(),
                $schema->getScopesCreatedAtColumn()   => $now,
            ]);

            $scope->setCreatedAt($now);

            return $scope;
        } catch (RepositoryException $exception) {
            $message = 'Scope creation failed.';
            throw new RepositoryException($message, 0, $exception);
        }
    }
117451
public function scopes($scopes)
    {
        $this->scopes = array_unique(array_merge($this->scopes, (array) $scopes));

        return $this;
    }
586259
public function get_row($query = '', $ignore_cache = false){
        if( empty($query) ){
            $query = $this->build_query();
            $this->clear();
        }
        if( $this->cache_exist($query) && !$ignore_cache ){
            return $this->get_cache($query);
        }else{
            return $this->db->get_row($query);
        }
    }
646516
protected function newQuery()
    {
        $query = app("es")->setModel($this);

        $query->connection($this->getConnection());

        if ($index = $this->getIndex()) {
            $query->index($index);
        }

        if ($type = $this->getType()) {
            $query->type($type);
        }

        return $query;
    }
341642
public function createQuery()
    {
        $query = $this->persistenceManager->createQueryForType($this->entityClassName);
        if ($this->defaultOrderings !== []) {
            $query->setOrderings($this->defaultOrderings);
        }
        return $query;
    }
380643
public static function putMapping($ignoreConflicts = false)
    {
        $instance = new static();

        $mapping = $instance->getBasicEsParams();

        $params = [
            '_source'       => ['enabled' => true],
            'properties'    => $instance->getMappingProperties(),
        ];

        $mapping['body'][$instance->getTypeName()] = $params;

        return $instance->getElasticSearchClient()->indices()->putMapping($mapping);
    }
902315
public static function queryBuilderStatic(array $options = []) : \Object\Query\Builder {
		$class = get_called_class();
		$model = new $class();
		return $model->queryBuilder($options);
	}
209052
public function addScopes(array $scopes): self
    {
        $this->scopes = array_merge($this->scopes, $scopes);

        return $this;
    }
1159405
protected function prepareQueryBuilder($columns = ['*'])
    {
        $builder = $this->query->applyScopes();

        return $builder->addSelect(
            $this->shouldSelect($builder->getQuery()->columns ? [] : $columns)
        );
    }
1244197
public function fresh($with = [])
    {
        if ($this->isEmpty()) {
            return new static;
        }

        $model = $this->first();

        $freshModels = $model->newQueryWithoutScopes()
            ->with(is_string($with) ? func_get_args() : $with)
            ->whereIn($model->getKeyName(), $this->modelKeys())
            ->get()
            ->getDictionary();

        return $this->map(function ($model) use ($freshModels) {
            return $model->exists && isset($freshModels[$model->getKey()])
                    ? $freshModels[$model->getKey()] : null;
        });
    }
1124093
public function getCastedQuery()
    {
        $newQuery = $this->castArray($this->query, $this->initialMetadata);
        ArrayModifier::aggregate($newQuery, self::$mongoDbQueryOperators);
        return $newQuery;
    }
1075975
protected function applyScope()
    {
        foreach ($this->scopeQuery as $callback) {
            if (is_callable($callback)) {
                $this->query = $callback($this->query);
            }
        }

        // Clear scopes
        $this->scopeQuery = [];

        return $this;
    }
928596
public function setScopes(Mutable $scopes = null)
    {
        if ($scopes && $scopes->count()) {
            $scopes->prepend(
                new Scope('all')
            );
        }

        $this->scopes = $scopes;

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

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

        return self::$whereBuilder;
    }
1307949
public function scopeFiltersApply(Builder $query, array $filters = []): Builder
    {
        foreach ($filters as $filter) {
            if (! is_object($filter)) {
                $filter = app()->make($filter);
            }

            $query = $filter->filter($query);
        }

        return $query;
    }
788250
public function withoutGlobalScopes(array $scopes = null)
    {
        if (! is_array($scopes)) {
            $scopes = array_keys($this->scopes);
        }

        foreach ($scopes as $scope) {
            $this->withoutGlobalScope($scope);
        }

        return $this;
    }