class Builder

Traits

Macroable

Constants

MIN_QUERY_SIZE

MAX_QUERY_SIZE

SPECIAL_CHARS

DIR_ASC

DIR_DESC

VALUE_TYPES

REPLACEMENT_ENTITIES

SORTING_DIRS

OP_EQ

OP_NEQ

OP_LT

OP_LTE

OP_GT

OP_GTE

OP_LIKE

OPERATORS

Properties

protected APIClient $connection
protected array $fields
protected array $relations
protected int $relation_id
protected int $size
protected string $orderBy
protected string $sortDir
protected array $query
protected bool $respectPublishingStatus
protected Closure $mapper
protected bool $assoc
protected bool $shouldCache
protected string $cacheKey
protected bool $debug
protected callable[] $appends
protected string $model

Methods

__construct(bool|null $respectPublishingStatus = true, array|null $query = null, Closure|null $mapper = null, $appends = [])

No description

connection(string|null $name)

No description

setConnectionName(string|null $connection)

No description

getConnectionName()

No description

getConnection()

No description

append(Closure $callback)

Append a query modifier

void
setModel(string $model)

No description

string|null
getModel()

No description

cacheResultsWithKey(string $key)

Cache the results with the given key

bool
hasRelation(string $relation)

No description

mixed
escapeValue(null|array|bool|int|string|DateTimeInterface $value, string $operator = null)

No description

string
compileTermQuery(string $field, null|array|bool|int|string|DateTimeInterface $value)

No description

string
compileNullQuery(string $field)

No description

string
compileScopedQuery(array $args, string $operator = 'AND')

No description

string
compileField(string $field)

Compiles the field name into something ES can understand

string
compileWhereQuery(string $field, $operator, null|array|Collection|bool|int|QueryableModel|string|DateTimeInterface $value)

No description

debug()

Sets the debug flag of the query Making the API reflect the compiled query in the output

string
getQuery(bool $scoped = false)

Compiles the query and retrieves the query string.

string
getRequest()

Compiles the query and retrieves the query string.

raw(string $query)

Performs a raw query, use carefully.

orderBy(string $field, string $direction = null)

Sets the field which to order the results by

orderDirection(string $direction)

Sets the direction to order the results by

relation(string|null $relation, int|null $relation_id = null)

Sets the relation for the query

relations(array $relations)

No description

limit(int $limit)

Limits the results to $limit amount of hits

fields(array $fields)

Sets which fields to retrieve (default: All fields)

field(string $field)

Adds a field that should be retrieved

where(...$args)

Performs a 'where' query

whereIn(string $field, array $values)

Queries where field exists in the values

whereBetween(string $field, null|array|bool|int|string|DateTimeInterface $from, null|array|bool|int|string|DateTimeInterface $to)

Queries where field is between $from and $to

whereNotBetween(string $field, null|array|bool|int|string|DateTimeInterface $from, null|array|bool|int|string|DateTimeInterface $to)

Queries where field is not between $from and $to

whereNot(...$args)

Performs a 'whereNot' query

orWhere(...$args)

Performs a 'orWhere' query

andWhere(...$args)

Performs a 'andWhere' query

PaginatedResult
paginate(int $size = 100, int $page = 1)

Creates a paginated result

assoc(bool $assoc)

Determines if we should return values as array or object

object
fetch(int $size = null, int $page = null)

Retrieves the raw query result from the API

Collection
get()

Retrieves the results of the query

getMapper()

No description

setMapper(callable $mapper)

No description

object|null
first()

Retrieves the first result

object|null
firstOrFail()

Retrieves the first result

Collection
all()

Retrives all results for the given query, ignoring the query limit

Collection
random(int|null $amount = null)

Returns random results for the given query

ignorePublishingStatus()

Also include unpublished results Only applies to entry and page relations

respectPublishingStatus($respect = true)

Only include published results Only applies to entry and page relations

int
count()

Get the count of items matching the current query

publishedAt(string|DateTimeInterface|null $date)

No description

string
compileQuery(bool $scoped = false)

No description

string
compileRequest($size = null, $page = null)

No description

if(bool|Closure $clause, Closure $then, Closure|null $else = null)

Conditional query

string
__toString()

No description

getSize()

No description

Details

at line 153
__construct(bool|null $respectPublishingStatus = true, array|null $query = null, Closure|null $mapper = null, $appends = [])

Parameters

bool|null $respectPublishingStatus
array|null $query
Closure|null $mapper
$appends

at line 165
Builder connection(string|null $name)

Parameters

string|null $name

Return Value

Builder

at line 174
Builder setConnectionName(string|null $connection)

Parameters

string|null $connection

Return Value

Builder

at line 180
getConnectionName()

at line 188
APIClient getConnection()

Return Value

APIClient

at line 199
Builder append(Closure $callback)

Append a query modifier

Parameters

Closure $callback

Return Value

Builder

at line 209
void setModel(string $model)

Parameters

string $model

Return Value

void

at line 217
string|null getModel()

Return Value

string|null

at line 228
Builder cacheResultsWithKey(string $key)

Cache the results with the given key

Parameters

string $key

Return Value

Builder

at line 240
protected bool hasRelation(string $relation)

Parameters

string $relation

Return Value

bool

at line 250
protected mixed escapeValue(null|array|bool|int|string|DateTimeInterface $value, string $operator = null)

Parameters

null|array|bool|int|string|DateTimeInterface $value
string $operator

Return Value

mixed

at line 278
protected string compileTermQuery(string $field, null|array|bool|int|string|DateTimeInterface $value)

Parameters

string $field
null|array|bool|int|string|DateTimeInterface $value

Return Value

string

at line 287
protected string compileNullQuery(string $field)

Parameters

string $field

Return Value

string

at line 297
protected string compileScopedQuery(array $args, string $operator = 'AND')

Parameters

array $args
string $operator

Return Value

string

at line 327
protected string compileField(string $field)

Compiles the field name into something ES can understand

Parameters

string $field

Return Value

string

at line 343
protected string compileWhereQuery(string $field, $operator, null|array|Collection|bool|int|QueryableModel|string|DateTimeInterface $value)

Parameters

string $field
$operator
null|array|Collection|bool|int|QueryableModel|string|DateTimeInterface $value

Return Value

string

Exceptions

InvalidOperatorException If an invalid operator is passed

at line 442
Builder debug()

Sets the debug flag of the query Making the API reflect the compiled query in the output

Return Value

Builder

at line 455
string getQuery(bool $scoped = false)

Compiles the query and retrieves the query string.

Used for debugging purposes.

Parameters

bool $scoped Determines if the query shouls be compiled in a scoped context.

Return Value

string

at line 467
string getRequest()

Compiles the query and retrieves the query string.

Used for debugging purposes.

Return Value

string

at line 478
Builder raw(string $query)

Performs a raw query, use carefully.

Parameters

string $query

Return Value

Builder

at line 492
Builder orderBy(string $field, string $direction = null)

Sets the field which to order the results by

Parameters

string $field
string $direction

Return Value

Builder

Exceptions

InvalidSortingDirectionException If an invalid $direction is passed

at line 510
Builder orderDirection(string $direction)

Sets the direction to order the results by

Parameters

string $direction

Return Value

Builder

Exceptions

InvalidSortingDirectionException If an invalid $direction is passed

at line 527
Builder relation(string|null $relation, int|null $relation_id = null)

Sets the relation for the query

Parameters

string|null $relation
int|null $relation_id

Return Value

Builder

at line 556
relations(array $relations)

Parameters

array $relations

at line 571
Builder limit(int $limit)

Limits the results to $limit amount of hits

Parameters

int $limit

Return Value

Builder

at line 585
Builder fields(array $fields)

Sets which fields to retrieve (default: All fields)

Parameters

array $fields

Return Value

Builder

at line 600
Builder field(string $field)

Adds a field that should be retrieved

Parameters

string $field

Return Value

Builder

at line 619
Builder where(...$args)

Performs a 'where' query

If a closure is passed as the only argument, a new query scope will be created. If $value is omitted, $operator is used as the $value, and the $operator will be set to '='.

Parameters

...$args

Return Value

Builder

at line 647
Builder whereIn(string $field, array $values)

Queries where field exists in the values

Parameters

string $field
array $values

Return Value

Builder

at line 660
Builder whereBetween(string $field, null|array|bool|int|string|DateTimeInterface $from, null|array|bool|int|string|DateTimeInterface $to)

Queries where field is between $from and $to

Parameters

string $field
null|array|bool|int|string|DateTimeInterface $from
null|array|bool|int|string|DateTimeInterface $to

Return Value

Builder

at line 677
Builder whereNotBetween(string $field, null|array|bool|int|string|DateTimeInterface $from, null|array|bool|int|string|DateTimeInterface $to)

Queries where field is not between $from and $to

Parameters

string $field
null|array|bool|int|string|DateTimeInterface $from
null|array|bool|int|string|DateTimeInterface $to

Return Value

Builder

at line 697
Builder whereNot(...$args)

Performs a 'whereNot' query

If a closure is passed as the only argument, a new query scope will be created. If $value is omitted, $operator is used as the $value, and the $operator will be set to '='.

Parameters

...$args

Return Value

Builder

at line 730
Builder orWhere(...$args)

Performs a 'orWhere' query

If a closure is passed as the only argument, a new query scope will be created. If $value is omitted, $operator is used as the $value, and the $operator will be set to '='.

Parameters

...$args

Return Value

Builder

Exceptions

InvalidAssignmentException If left hand side of query is not set

at line 752
Builder andWhere(...$args)

Performs a 'andWhere' query

If a closure is passed as the only argument, a new query scope will be created. If $value is omitted, $operator is used as the $value, and the $operator will be set to '='.

Parameters

...$args

Return Value

Builder

Exceptions

InvalidAssignmentException If left hand side of query is not set

at line 770
PaginatedResult paginate(int $size = 100, int $page = 1)

Creates a paginated result

Parameters

int $size
int $page

Return Value

PaginatedResult

Exceptions

QueryException

at line 785
Builder assoc(bool $assoc)

Determines if we should return values as array or object

Parameters

bool $assoc

Return Value

Builder

at line 799
object fetch(int $size = null, int $page = null)

Retrieves the raw query result from the API

Parameters

int $size
int $page

Return Value

object

Exceptions

QueryException

at line 835
Collection get()

Retrieves the results of the query

Return Value

Collection

Exceptions

QueryException

at line 847
getMapper()

at line 856
Builder setMapper(callable $mapper)

Parameters

callable $mapper

Return Value

Builder

at line 868
object|null first()

Retrieves the first result

Return Value

object|null

Exceptions

QueryException

at line 885
object|null firstOrFail()

Retrieves the first result

Return Value

object|null

Exceptions

NotFoundException
QueryException

at line 904
Collection all()

Retrives all results for the given query, ignoring the query limit

Return Value

Collection

at line 920
Collection random(int|null $amount = null)

Returns random results for the given query

Parameters

int|null $amount If not provided, will use the current query limit

Return Value

Collection

Exceptions

QueryException

at line 972
Builder ignorePublishingStatus()

Also include unpublished results Only applies to entry and page relations

Return Value

Builder

at line 986
Builder respectPublishingStatus($respect = true)

Only include published results Only applies to entry and page relations

Parameters

$respect

Return Value

Builder

at line 998
int count()

Get the count of items matching the current query

Return Value

int

Exceptions

QueryException

at line 1014
publishedAt(string|DateTimeInterface|null $date)

Parameters

string|DateTimeInterface|null $date

at line 1053
protected string compileQuery(bool $scoped = false)

Parameters

bool $scoped

Return Value

string

at line 1077
protected string compileRequest($size = null, $page = null)

Parameters

$size
$page

Return Value

string

at line 1114
Builder if(bool|Closure $clause, Closure $then, Closure|null $else = null)

Conditional query

Parameters

bool|Closure $clause
Closure $then
Closure|null $else

Return Value

Builder

at line 1134
string __toString()

Return Value

string

at line 1139
getSize()