trait Queryable

Properties

protected string $defaultOrderByField Determines the default field to order the query by
protected string $defaultSortDirection Determines the default direction to order the query by

Methods

static Builder
makeQueryBuilder($appends = [])

No description

bool
respectPublishingStatus()

Determine if this object respects publishing statuses when performing queries

static Builder
disregardingPublishingStatus(bool $disregarding = true)

Override the publishing status for the model

static Builder
field(...$args)

Adds a field that should be retrieved

static Builder
fields(...$args)

Sets which fields to retrieve (default: All fields)

static Builder
limit(...$args)

Limits the results to $limit amount of hits

static Builder
orderBy(...$args)

Sets the field which to order the results by

static Builder
raw(...$args)

Performs a raw query, use carefully.

static Builder
publishedAt(...$args)

Performs a 'publishedAt' query

static Builder
where(...$args)

Performs a 'where' query

static Builder
whereIn(...$args)

Queries where field exists in the values

static Builder
whereNot(...$args)

Performs a 'whereNot' query

static 
whereBetween(...$args)

No description

static 
whereNotBetween(...$args)

No description

static Paginator
paginate(...$args)

Creates a paginated result

static mixed
maybeMutatesCache(string $key, bool $shouldCache, Closure $action)

Perform an action and mutate the given key if $shouldCache is true

static Builder
maybeCacheResults(string $key, bool $shouldCache)

Cache the results with the given key if $shouldCache is true

static Builder
cacheResults(string $key)

Cache the results with the given key

static int
count(...$args)

Get the count of items matching the current query

static Queryable|Collection
random(int $amount = 1)

Picks random items

static Builder
query(string $query = '*')

No description

Details

at line 39
static protected Builder makeQueryBuilder($appends = [])

Parameters

$appends

Return Value

Builder

Exceptions

NotQueryableException If object not queryable

at line 99
bool respectPublishingStatus()

Determine if this object respects publishing statuses when performing queries

Return Value

bool

at line 111
static Builder disregardingPublishingStatus(bool $disregarding = true)

Override the publishing status for the model

Parameters

bool $disregarding

Return Value

Builder

at line 125
static Builder field(...$args)

Adds a field that should be retrieved

Parameters

...$args

Return Value

Builder

Exceptions

NotQueryableException If object not queryable

See also

Builder::field

at line 138
static Builder fields(...$args)

Sets which fields to retrieve (default: All fields)

Parameters

...$args

Return Value

Builder

Exceptions

NotQueryableException If object not queryable

See also

Builder::fields

at line 151
static Builder limit(...$args)

Limits the results to $limit amount of hits

Parameters

...$args

Return Value

Builder

Exceptions

NotQueryableException If object not queryable

See also

Builder::limit

at line 166
static Builder orderBy(...$args)

Sets the field which to order the results by

Parameters

...$args

Return Value

Builder

Exceptions

InvalidSortingDirectionException If an invalid $direction is passed
NotQueryableException If object not queryable

See also

Builder::orderBy

at line 179
static Builder raw(...$args)

Performs a raw query, use carefully.

Parameters

...$args

Return Value

Builder

Exceptions

NotQueryableException If object not queryable

See also

Builder::raw

at line 192
static Builder publishedAt(...$args)

Performs a 'publishedAt' query

Parameters

...$args

Return Value

Builder

Exceptions

NotQueryableException If object not queryable

See also

Builder::publishedAt

at line 210
static 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

Exceptions

NotQueryableException If object not queryable

See also

Builder::where

at line 224
static Builder whereIn(...$args)

Queries where field exists in the values

Parameters

...$args

Return Value

Builder

Exceptions

NotQueryableException If object not queryable

See also

Builder::whereIn

at line 242
static 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

Exceptions

NotQueryableException If object not queryable

See also

Builder::whereNot

at line 257
static whereBetween(...$args)

Parameters

...$args

at line 272
static whereNotBetween(...$args)

Parameters

...$args

at line 287
static Paginator paginate(...$args)

Creates a paginated result

Parameters

...$args

Return Value

Paginator

Exceptions

NotQueryableException If object not queryable
QueryException On invalid query

See also

Builder::paginate

at line 303
static mixed maybeMutatesCache(string $key, bool $shouldCache, Closure $action)

Perform an action and mutate the given key if $shouldCache is true

Parameters

string $key
bool $shouldCache
Closure $action

Return Value

mixed

at line 320
static Builder maybeCacheResults(string $key, bool $shouldCache)

Cache the results with the given key if $shouldCache is true

Parameters

string $key
bool $shouldCache

Return Value

Builder

See also

Builder::cacheResultsWithKey

at line 336
static Builder cacheResults(string $key)

Cache the results with the given key

Parameters

string $key

Return Value

Builder

See also

Builder::cacheResultsWithKey

at line 349
static int count(...$args)

Get the count of items matching the current query

Parameters

...$args

Return Value

int

Exceptions

NotQueryableException If object not queryable
QueryException On invalid query

See also

Builder::count

at line 360
static Queryable|Collection random(int $amount = 1)

Picks random items

Parameters

int $amount

Return Value

Queryable|Collection

at line 372
static Builder query(string $query = '*')

Parameters

string $query

Return Value

Builder

Exceptions

NotQueryableException