class BelongsToPolymorphic extends BelongsTo

Belongs to polymorphic relation.

Constants

EAGER_LOAD_CHUNK_SIZE

Eager load chunk size.

Properties

protected Connection $connection Database connection. from Query
protected HelperInterface $helper Query helper. from Query
protected Compiler $compiler Query compiler. from Query
protected mixed $table Database table. from Query
protected bool $distinct Select distinct? from Query
protected array $commonTableExpressions Common table expressions. from Query
protected array $setOperations Set operations. from Query
protected array $columns Columns from which we are fetching data. from Query
protected array $wheres WHERE clauses. from Query
protected array $joins JOIN clauses. from Query
protected array $groupings GROUP BY clauses. from Query
protected array $havings HAVING clauses. from Query
protected array $orderings ORDER BY clauses. from Query
protected int|null $limit Limit. from Query
protected int|null $offset Offset. from Query
protected bool|string|null $lock Lock. from Query
protected string|null $prefix Prefix. from Query
protected bool $inSubqueryContext Is the query in subquery context? from Query
static protected PaginationFactoryInterface|Closure $paginationFactory Pagination factory. from Query
protected ORM $model Instance of the model to hydrate. from Query
protected string $modelClass Class name of the model we're hydrating. from Query
protected array $relationCounters Relation count subqueries. from Query
protected ORM $origin Originating record. from Relation
protected string $foreignKey Foreign key. from Relation
protected bool $lazy Are we lazy load related records? from Relation

Methods

__construct(Connection $connection, ORM $origin, ORM $model, string $polymorphicType)

Constructor.

__clone()

Create a fresh compiler instance and clone set operation queries when we clone the query.

from Query
reset()

Resets the query to its default state.

from Query
newInstance()

Returns a new query builder instance.

from Query
$this
inSubqueryContext()

Sets the query to subquery context.

from Query
static 
setPaginationFactory(PaginationFactoryInterface|Closure $factory)

Sets the pagination factory.

from Query
getPaginationFactory()

Gets the pagination factory.

from Query
getConnection()

Returns the connection instance.

from Query
getCompiler()

Returns query compiler instance.

from Query
array
getCommonTableExpressions()

Returns the common set operations.

from Query
array
getSetOperations()

Returns the set operations.

from Query
mixed
getTable()

Returns the database table.

from Query
bool
isDistinct()

Is it a distict select?

from Query
array
getColumns()

Returns the columns from which we are fetching data.

from Query
array
getWheres()

Returns WHERE clauses.

from Query
array
getJoins()

Returns JOIN clauses.

from Query
array
getGroupings()

Returns GROUP BY clauses.

from Query
array
getHavings()

Returns HAVING clauses.

from Query
array
getOrderings()

Returns ORDER BY clauses.

from Query
int|null
getLimit()

Returns the limit.

from Query
int|null
getOffset()

Returns the offset.

from Query
bool|string|null
getLock()

Returns the lock.

from Query
string|null
getPrefix()

Returns the prefix.

from Query
$this
forCompiler(string $compilerClass, Closure $query)

Executes the closure if the compiler is of the correct class.

from Query
$this
with(string $name, array $columns, Subquery $query)

Adds a common table expression.

from Query
$this
withRecursive(string $name, array $columns, Subquery $query)

Adds a recursive common table expression.

from Query
$this
setOperation(string $operation)

Adds a set operation.

from Query
$this
union()

Adds a UNION operation.

from Query
$this
unionAll()

Adds a UNION ALL operation.

from Query
$this
intersect()

Adds a INTERSECT operation.

from Query
$this
intersectAll()

Adds a INTERSECT ALL operation.

from Query
$this
except()

Adds a EXCEPT operation.

from Query
$this
exceptAll()

Adds a EXCEPT ALL operation.

from Query
$this
table(string|array|Subquery|Raw|null $table)

Sets table we want to query.

from Query
$this
from(string|array|Subquery|Raw|null $table)

Alias of Query::table().

from Query
$this
into(string|array|Subquery|Raw|null $table)

Alias of Query::table().

from Query
$this
select(array $columns)

Sets the columns we want to select.

from Query
$this
selectRaw(string $sql, array $parameters = [])

Sets the columns we want to select using raw SQL.

from Query
$this
distinct()

Select distinct?

from Query
$this
where(string|array|Closure $column, string|null $operator = null, mixed $value = null, string $separator = 'AND')

Adds a WHERE clause.

from Query
$this
whereRaw(string|array $column, string|array|null $operator = null, string|null $raw = null, string $separator = 'AND')

Adds a raw WHERE clause.

from Query
$this
orWhere(string|array|Closure $column, string|null $operator = null, mixed $value = null)

Adds a OR WHERE clause.

from Query
$this
orWhereRaw(string|array $column, string|array|null $operator = null, string|null $raw = null)

Adds a raw OR WHERE clause.

from Query
$this
whereDate(string $column, string $operator, string|DateTimeInterface $date, string $separator = 'AND')

Adds a date comparison clause.

from Query
$this
orWhereDate(string $column, string $operator, string|DateTimeInterface $date)

Adds a date comparison clause.

from Query
$this
whereColumn(string|array $column1, string $operator, string|array $column2, string $separator = 'AND')

Adds a column comparison clause.

from Query
$this
orWhereColumn(string|array $column1, string $operator, string|array $column2)

Adds a column comparison clause.

from Query
$this
between(mixed $column, mixed $value1, mixed $value2, string $separator = 'AND', bool $not = false)

Adds a BETWEEN clause.

from Query
$this
orBetween(mixed $column, mixed $value1, mixed $value2)

Adds a OR BETWEEN clause.

from Query
$this
notBetween(mixed $column, mixed $value1, mixed $value2)

Adds a NOT BETWEEN clause.

from Query
$this
orNotBetween(mixed $column, mixed $value1, mixed $value2)

Adds a OR NOT BETWEEN clause.

from Query
$this
betweenDate(string $column, string|DateTimeInterface $date1, string|DateTimeInterface $date2, string $separator = 'AND', bool $not = false)

Adds a date range clause.

from Query
orBetweenDate(string $column, string|DateTimeInterface $date1, string|DateTimeInterface $date2)

Adds a date range clause.

from Query
notBetweenDate(string $column, string|DateTimeInterface $date1, string|DateTimeInterface $date2)

Adds a date range clause.

from Query
orNotBetweenDate(string $column, string|DateTimeInterface $date1, string|DateTimeInterface $date2)

Adds a date range clause.

from Query
$this
in(mixed $column, array|Raw|Subquery $values, string $separator = 'AND', bool $not = false)

Adds a IN clause.

from Query
$this
orIn(mixed $column, array|Raw|Subquery $values)

Adds a OR IN clause.

from Query
$this
notIn(mixed $column, array|Raw|Subquery $values)

Adds a NOT IN clause.

from Query
$this
orNotIn(mixed $column, array|Raw|Subquery $values)

Adds a OR NOT IN clause.

from Query
$this
isNull(mixed $column, string $separator = 'AND', bool $not = false)

Adds a IS NULL clause.

from Query
$this
orIsNull(mixed $column)

Adds a OR IS NULL clause.

from Query
$this
isNotNull(mixed $column)

Adds a IS NOT NULL clause.

from Query
$this
orIsNotNull(mixed $column)

Adds a OR IS NOT NULL clause.

from Query
$this
exists(Subquery $query, string $separator = 'AND', bool $not = false)

Adds a EXISTS clause.

from Query
$this
orExists(Subquery $query)

Adds a OR EXISTS clause.

from Query
$this
notExists(Subquery $query)

Adds a NOT EXISTS clause.

from Query
$this
orNotExists(Subquery $query)

Adds a OR NOT EXISTS clause.

from Query
$this
join(string $table, string|Closure $column1 = null, string $operator = null, string $column2 = null, string $type = 'INNER', bool $raw = false)

Adds a JOIN clause.

from Query
$this
joinRaw(string $table, string $column1, string $operator, string $raw, string $type = 'INNER')

Adds a raw JOIN clause.

from Query
$this
leftJoin(string $table, string|Closure $column1 = null, string $operator = null, string $column2 = null)

Adds a LEFT OUTER JOIN clause.

from Query
$this
leftJoinRaw(string $table, string $column1, string $operator, string $raw)

Adds a raw LEFT OUTER JOIN clause.

from Query
$this
groupBy(string|array $columns)

Adds a GROUP BY clause.

from Query
$this
having(string $column, string $operator, mixed $value, string $separator = 'AND')

Adds a HAVING clause.

from Query
$this
havingRaw(string $raw, string $operator, mixed $value, string $separator = 'AND')

Adds a raw HAVING clause.

from Query
$this
orHaving(string $column, string $operator, mixed $value)

Adds a OR HAVING clause.

from Query
$this
orHavingRaw(string $raw, string $operator, mixed $value)

Adds a raw OR HAVING clause.

from Query
$this
orderBy(string|array $columns, string $order = 'ASC')

Adds a ORDER BY clause.

from Query
$this
orderByRaw(string $raw, array $parameters = [], string $order = 'ASC')

Adds a raw ORDER BY clause.

from Query
$this
ascending(string|array $columns)

Adds an ascending ORDER BY clause.

from Query
$this
ascendingRaw(string $raw, array $parameters = [])

Adds a raw ascending ORDER BY clause.

from Query
$this
descending(string|array $columns)

Adds a descending ORDER BY clause.

from Query
$this
descendingRaw(string $raw, array $parameters = [])

Adds a raw descending ORDER BY clause.

from Query
$this
clearOrderings()

Clears the ordering clauses.

from Query
$this
limit(int $limit)

Adds a LIMIT clause.

from Query
$this
offset(int $offset)

Adds a OFFSET clause.

from Query
$this
lock(bool|string $lock = true)

Enable lock.

from Query
$this
sharedLock()

Enable shared lock.

from Query
$this
prefix(string $prefix)

Adds a query prefix.

from Query
mixed
fetchFirst(mixed ...$fetchMode)

Executes a SELECT query and returns the first row of the result set or NULL if nothing is found.

from Query
mixed
first()

Returns a single record from the database.

from Relation
createResultSet(array $results)

Creates a result set.

from Query
array|ResultSet
fetchAll(bool $returnResultSet, mixed ...$fetchMode)

Executes a SELECT query and returns an array containing all of the result set rows.

from Query
all()

Returns a result set from the database.

from Relation
mixed
column(string $column = null)

Executes a SELECT query and returns the value of the chosen column of the first row of the result set.

from Query
array
columns(string $column = null)

Executes a SELECT query and returns an array containing the values of the indicated 0-indexed column.

from Query
array
pairs(string $key, string $value)

Executes a SELECT query and returns an array where the first column is used as keys and the second as values.

from Query
fetchYield(mixed ...$fetchMode)

Executes a SELECT query and returns a generator that lets you iterate over the results.

from Query
yield()

Returns a generator that lets you iterate over the results.

from Query
int
paginationCount()

Returns the number of records that the query will return.

from Query
paginate($itemsPerPage = null, array $options = [])

No description

from Query
batch(Closure $processor, int $batchSize = 1000, int $offsetStart = 0, int|null $offsetEnd = null)

Fetches data in batches and passes them to the processor closure.

from Query
mixed
aggregate(string $function, string|array $column)

Sets the selected column of the query to the chosen aggreate.

from Query
mixed
min(string $column)

Returns the minimum value for the chosen column.

from Query
mixed
max(string $column)

Returns the maximum value for the chosen column.

from Query
mixed
sum(string $column)

Returns sum of all the values in the chosen column.

from Query
mixed
avg(string $column)

Returns the average value for the chosen column.

from Query
int
count(string $column = '*')

Returns the number of rows.

from Query
int
countDistinct(string|array $column)

Returns the number of distinct values of the chosen column.

from Query
bool
insert(array $values = [])

Inserts data into the chosen table.

from Query
int|false
insertAndGetId(array $values, string $primaryKey = 'id')

Inserts data into the chosen table and returns the auto increment id.

from Query
int
update(array $values)

Updates data from the chosen table.

from Query
int
increment(string $column, int $increment = 1)

Increments column value.

from Query
int
decrement(string $column, int $decrement = 1)

Decrements column value.

from Query
int
delete()

Deletes data from the chosen table.

from Query
ORM
getModel()

Returns the model.

from Query
ORM|null
get(int|string $id, array $columns = [])

Returns a record using the value of its primary key.

from Query
$this
including(string|array|false $includes)

Adds relations to eager load.

from Query
$this
excluding(string|array|true $excludes)

Removes relations to eager load.

from Query
array
parseRelationCountName(string $relation)

Parses the count relation name and returns an array consisting of the relation name and the chosen alias.

from Query
$this
withCountOf(string|array $relations)

Adds subqueries that count the number of related records for the chosen relations.

from Query
ORM
hydrateModel(array $result)

Returns a hydrated model.

from Query
array
parseIncludes()

Parses includes.

from Query
loadIncludes(array $results)

Load includes.

from Query
array
hydrateModelsAndLoadIncludes(mixed $results)

Returns hydrated models.

from Query
$this
scope(string $scope, mixed ...$arguments)

Calls a scope method on the model.

from Query
string
getForeignKey()

Returns the foreign key name.

from BelongsTo
array
keys(array $results)

Returns the keys used to eagerly load records.

from BelongsTo
lazyCriterion()

Sets the criterion used when lazy loading related records.

from BelongsTo
$this
eagerCriterion(array $keys)

Sets the criterion used when eager loading related records.

from BelongsTo
eagerLoadChunked(array $keys)

Eager loads records in chunks.

from Relation
$this
getRelationCountQuery()

Returns a query instance used to build relation count subqueries.

from BelongsTo
adjustQuery()

Adjusts the query.

from Relation
eagerLoad(array $results, string $relation, Closure|null $criteria, array $includes)

Eager loads related records and matches them with their originating records.

from BelongsTo
ORM|null
getRelated()

Returns related a record from the database.

from BelongsTo

Details

at line 28
__construct(Connection $connection, ORM $origin, ORM $model, string $polymorphicType)

Constructor.

Parameters

Connection $connection Database connection
ORM $origin Originating model
ORM $model Model to hydrate
string $polymorphicType Polymorphic type

in Query at line 182
__clone()

Create a fresh compiler instance and clone set operation queries when we clone the query.

in Query at line 195
protected reset()

Resets the query to its default state.

in Query at line 210
Query newInstance()

Returns a new query builder instance.

Return Value

Query

in Query at line 220
$this inSubqueryContext()

Sets the query to subquery context.

Return Value

$this

in Query at line 232
static setPaginationFactory(PaginationFactoryInterface|Closure $factory)

Sets the pagination factory.

Parameters

PaginationFactoryInterface|Closure $factory Pagination factory

in Query at line 242
static PaginationFactoryInterface getPaginationFactory()

Gets the pagination factory.

in Query at line 259
Connection getConnection()

Returns the connection instance.

Return Value

Connection

in Query at line 269
Compiler getCompiler()

Returns query compiler instance.

Return Value

Compiler

in Query at line 279
array getCommonTableExpressions()

Returns the common set operations.

Return Value

array

in Query at line 289
array getSetOperations()

Returns the set operations.

Return Value

array

in Query at line 299
mixed getTable()

Returns the database table.

Return Value

mixed

in Query at line 309
bool isDistinct()

Is it a distict select?

Return Value

bool

in Query at line 81
array getColumns()

Returns the columns from which we are fetching data.

Return Value

array

in Query at line 329
array getWheres()

Returns WHERE clauses.

Return Value

array

in Query at line 339
array getJoins()

Returns JOIN clauses.

Return Value

array

in Query at line 349
array getGroupings()

Returns GROUP BY clauses.

Return Value

array

in Query at line 359
array getHavings()

Returns HAVING clauses.

Return Value

array

in Query at line 369
array getOrderings()

Returns ORDER BY clauses.

Return Value

array

in Query at line 379
int|null getLimit()

Returns the limit.

Return Value

int|null

in Query at line 389
int|null getOffset()

Returns the offset.

Return Value

int|null

in Query at line 399
bool|string|null getLock()

Returns the lock.

Return Value

bool|string|null

in Query at line 409
string|null getPrefix()

Returns the prefix.

Return Value

string|null

in Query at line 421
$this forCompiler(string $compilerClass, Closure $query)

Executes the closure if the compiler is of the correct class.

Parameters

string $compilerClass Compiler class name
Closure $query Closure

Return Value

$this

in Query at line 439
$this with(string $name, array $columns, Subquery $query)

Adds a common table expression.

Parameters

string $name Table name
array $columns Column names
Subquery $query Query

Return Value

$this

in Query at line 459
$this withRecursive(string $name, array $columns, Subquery $query)

Adds a recursive common table expression.

Parameters

string $name Table name
array $columns Column names
Subquery $query Query

Return Value

$this

in Query at line 472
protected $this setOperation(string $operation)

Adds a set operation.

Parameters

string $operation Operation

Return Value

$this

in Query at line 492
$this union()

Adds a UNION operation.

Return Value

$this

in Query at line 502
$this unionAll()

Adds a UNION ALL operation.

Return Value

$this

in Query at line 512
$this intersect()

Adds a INTERSECT operation.

Return Value

$this

in Query at line 522
$this intersectAll()

Adds a INTERSECT ALL operation.

Return Value

$this

in Query at line 532
$this except()

Adds a EXCEPT operation.

Return Value

$this

in Query at line 542
$this exceptAll()

Adds a EXCEPT ALL operation.

Return Value

$this

in Query at line 553
$this table(string|array|Subquery|Raw|null $table)

Sets table we want to query.

Parameters

string|array|Subquery|Raw|null $table Database table or subquery

Return Value

$this

in Query at line 566
$this from(string|array|Subquery|Raw|null $table)

Alias of Query::table().

Parameters

string|array|Subquery|Raw|null $table Database table or subquery

Return Value

$this

in Query at line 577
$this into(string|array|Subquery|Raw|null $table)

Alias of Query::table().

Parameters

string|array|Subquery|Raw|null $table Database table or subquery

Return Value

$this

in Query at line 588
$this select(array $columns)

Sets the columns we want to select.

Parameters

array $columns Array of columns we want to select from

Return Value

$this

in Query at line 602
$this selectRaw(string $sql, array $parameters = [])

Sets the columns we want to select using raw SQL.

Parameters

string $sql Raw sql
array $parameters Parameters

Return Value

$this

in Query at line 614
$this distinct()

Select distinct?

Return Value

$this

in Query at line 630
$this where(string|array|Closure $column, string|null $operator = null, mixed $value = null, string $separator = 'AND')

Adds a WHERE clause.

Parameters

string|array|Closure $column Column name, an array of column names or closure
string|null $operator Operator
mixed $value Value
string $separator Clause separator

Return Value

$this

in Query at line 669
$this whereRaw(string|array $column, string|array|null $operator = null, string|null $raw = null, string $separator = 'AND')

Adds a raw WHERE clause.

Parameters

string|array $column Column name, an array of column names or raw SQL
string|array|null $operator Operator or parameters
string|null $raw Raw SQL
string $separator Clause separator

Return Value

$this

in Query at line 694
$this orWhere(string|array|Closure $column, string|null $operator = null, mixed $value = null)

Adds a OR WHERE clause.

Parameters

string|array|Closure $column Column name, an array of column names or closure
string|null $operator Operator
mixed $value Value

Return Value

$this

in Query at line 707
$this orWhereRaw(string|array $column, string|array|null $operator = null, string|null $raw = null)

Adds a raw OR WHERE clause.

Parameters

string|array $column Column name, and array of column names or raw SQL
string|array|null $operator Operator or parameters
string|null $raw Raw SQL

Return Value

$this

in Query at line 721
$this whereDate(string $column, string $operator, string|DateTimeInterface $date, string $separator = 'AND')

Adds a date comparison clause.

Parameters

string $column Column name
string $operator Operator
string|DateTimeInterface $date Date
string $separator Separator

Return Value

$this

in Query at line 744
$this orWhereDate(string $column, string $operator, string|DateTimeInterface $date)

Adds a date comparison clause.

Parameters

string $column Column name
string $operator Operator
string|DateTimeInterface $date Date

Return Value

$this

in Query at line 758
$this whereColumn(string|array $column1, string $operator, string|array $column2, string $separator = 'AND')

Adds a column comparison clause.

Parameters

string|array $column1 Column name of array of column names
string $operator Operator
string|array $column2 Column name of array of column names
string $separator Separator

Return Value

$this

in Query at line 780
$this orWhereColumn(string|array $column1, string $operator, string|array $column2)

Adds a column comparison clause.

Parameters

string|array $column1 Column name of array of column names
string $operator Operator
string|array $column2 Column name of array of column names

Return Value

$this

in Query at line 795
$this between(mixed $column, mixed $value1, mixed $value2, string $separator = 'AND', bool $not = false)

Adds a BETWEEN clause.

Parameters

mixed $column Column name
mixed $value1 First value
mixed $value2 Second value
string $separator Clause separator
bool $not Not between?

Return Value

$this

in Query at line 818
$this orBetween(mixed $column, mixed $value1, mixed $value2)

Adds a OR BETWEEN clause.

Parameters

mixed $column Column name
mixed $value1 First value
mixed $value2 Second value

Return Value

$this

in Query at line 831
$this notBetween(mixed $column, mixed $value1, mixed $value2)

Adds a NOT BETWEEN clause.

Parameters

mixed $column Column name
mixed $value1 First value
mixed $value2 Second value

Return Value

$this

in Query at line 844
$this orNotBetween(mixed $column, mixed $value1, mixed $value2)

Adds a OR NOT BETWEEN clause.

Parameters

mixed $column Column name
mixed $value1 First value
mixed $value2 Second value

Return Value

$this

in Query at line 859
$this betweenDate(string $column, string|DateTimeInterface $date1, string|DateTimeInterface $date2, string $separator = 'AND', bool $not = false)

Adds a date range clause.

Parameters

string $column Column name
string|DateTimeInterface $date1 First date
string|DateTimeInterface $date2 Second date
string $separator Separator
bool $not Not between?

Return Value

$this

in Query at line 881
orBetweenDate(string $column, string|DateTimeInterface $date1, string|DateTimeInterface $date2)

Adds a date range clause.

Parameters

string $column Column name
string|DateTimeInterface $date1 First date
string|DateTimeInterface $date2 Second date

in Query at line 893
notBetweenDate(string $column, string|DateTimeInterface $date1, string|DateTimeInterface $date2)

Adds a date range clause.

Parameters

string $column Column name
string|DateTimeInterface $date1 First date
string|DateTimeInterface $date2 Second date

in Query at line 905
orNotBetweenDate(string $column, string|DateTimeInterface $date1, string|DateTimeInterface $date2)

Adds a date range clause.

Parameters

string $column Column name
string|DateTimeInterface $date1 First date
string|DateTimeInterface $date2 Second date

in Query at line 919
$this in(mixed $column, array|Raw|Subquery $values, string $separator = 'AND', bool $not = false)

Adds a IN clause.

Parameters

mixed $column Column name
array|Raw|Subquery $values Array of values or Subquery
string $separator Clause separator
bool $not Not in?

Return Value

$this

in Query at line 940
$this orIn(mixed $column, array|Raw|Subquery $values)

Adds a OR IN clause.

Parameters

mixed $column Column name
array|Raw|Subquery $values Array of values or Subquery

Return Value

$this

in Query at line 952
$this notIn(mixed $column, array|Raw|Subquery $values)

Adds a NOT IN clause.

Parameters

mixed $column Column name
array|Raw|Subquery $values Array of values or Subquery

Return Value

$this

in Query at line 964
$this orNotIn(mixed $column, array|Raw|Subquery $values)

Adds a OR NOT IN clause.

Parameters

mixed $column Column name
array|Raw|Subquery $values Array of values or Subquery

Return Value

$this

in Query at line 977
$this isNull(mixed $column, string $separator = 'AND', bool $not = false)

Adds a IS NULL clause.

Parameters

mixed $column Column name
string $separator Clause separator
bool $not Not in?

Return Value

$this

in Query at line 996
$this orIsNull(mixed $column)

Adds a OR IS NULL clause.

Parameters

mixed $column Column name

Return Value

$this

in Query at line 1007
$this isNotNull(mixed $column)

Adds a IS NOT NULL clause.

Parameters

mixed $column Column name

Return Value

$this

in Query at line 1018
$this orIsNotNull(mixed $column)

Adds a OR IS NOT NULL clause.

Parameters

mixed $column Column name

Return Value

$this

in Query at line 1031
$this exists(Subquery $query, string $separator = 'AND', bool $not = false)

Adds a EXISTS clause.

Parameters

Subquery $query Subquery
string $separator Clause separator
bool $not Not exists?

Return Value

$this

in Query at line 1050
$this orExists(Subquery $query)

Adds a OR EXISTS clause.

Parameters

Subquery $query Subquery

Return Value

$this

in Query at line 1061
$this notExists(Subquery $query)

Adds a NOT EXISTS clause.

Parameters

Subquery $query Subquery

Return Value

$this

in Query at line 1072
$this orNotExists(Subquery $query)

Adds a OR NOT EXISTS clause.

Parameters

Subquery $query Subquery

Return Value

$this

in Query at line 104
$this join(string $table, string|Closure $column1 = null, string $operator = null, string $column2 = null, string $type = 'INNER', bool $raw = false)

Adds a JOIN clause.

Parameters

string $table Table name
string|Closure $column1 Column name or closure
string $operator Operator
string $column2 Column name
string $type Join type
bool $raw Raw join?

Return Value

$this

in Query at line 1123
$this joinRaw(string $table, string $column1, string $operator, string $raw, string $type = 'INNER')

Adds a raw JOIN clause.

Parameters

string $table Table name
string $column1 Column name or closure
string $operator Operator
string $raw Raw SQL
string $type Join type

Return Value

$this

in Query at line 1137
$this leftJoin(string $table, string|Closure $column1 = null, string $operator = null, string $column2 = null)

Adds a LEFT OUTER JOIN clause.

Parameters

string $table Table name
string|Closure $column1 Column name or closure
string $operator Operator
string $column2 Column name

Return Value

$this

in Query at line 1151
$this leftJoinRaw(string $table, string $column1, string $operator, string $raw)

Adds a raw LEFT OUTER JOIN clause.

Parameters

string $table Table name
string $column1 Column name or closure
string $operator Operator
string $raw Raw SQL

Return Value

$this

in Query at line 1162
$this groupBy(string|array $columns)

Adds a GROUP BY clause.

Parameters

string|array $columns Column name or array of column names

Return Value

$this

in Query at line 1178
$this having(string $column, string $operator, mixed $value, string $separator = 'AND')

Adds a HAVING clause.

Parameters

string $column Column name
string $operator Operator
mixed $value Value
string $separator Clause separator

Return Value

$this

in Query at line 1200
$this havingRaw(string $raw, string $operator, mixed $value, string $separator = 'AND')

Adds a raw HAVING clause.

Parameters

string $raw Raw SQL
string $operator Operator
mixed $value Value
string $separator Clause separator

Return Value

$this

in Query at line 1213
$this orHaving(string $column, string $operator, mixed $value)

Adds a OR HAVING clause.

Parameters

string $column Column name
string $operator Operator
mixed $value Value

Return Value

$this

in Query at line 1226
$this orHavingRaw(string $raw, string $operator, mixed $value)

Adds a raw OR HAVING clause.

Parameters

string $raw Raw SQL
string $operator Operator
mixed $value Value

Return Value

$this

in Query at line 1238
$this orderBy(string|array $columns, string $order = 'ASC')

Adds a ORDER BY clause.

Parameters

string|array $columns Column name or array of column names
string $order Sorting order

Return Value

$this

in Query at line 1257
$this orderByRaw(string $raw, array $parameters = [], string $order = 'ASC')

Adds a raw ORDER BY clause.

Parameters

string $raw Raw SQL
array $parameters Parameters
string $order Sorting order

Return Value

$this

in Query at line 1268
$this ascending(string|array $columns)

Adds an ascending ORDER BY clause.

Parameters

string|array $columns Column name or array of column names

Return Value

$this

in Query at line 1280
$this ascendingRaw(string $raw, array $parameters = [])

Adds a raw ascending ORDER BY clause.

Parameters

string $raw Raw SQL
array $parameters Parameters

Return Value

$this

in Query at line 1291
$this descending(string|array $columns)

Adds a descending ORDER BY clause.

Parameters

string|array $columns Column name or array of column names

Return Value

$this

in Query at line 1303
$this descendingRaw(string $raw, array $parameters = [])

Adds a raw descending ORDER BY clause.

Parameters

string $raw Raw SQL
array $parameters Parameters

Return Value

$this

in Query at line 1313
$this clearOrderings()

Clears the ordering clauses.

Return Value

$this

in Query at line 1326
$this limit(int $limit)

Adds a LIMIT clause.

Parameters

int $limit Limit

Return Value

$this

in Query at line 1339
$this offset(int $offset)

Adds a OFFSET clause.

Parameters

int $offset Offset

Return Value

$this

in Query at line 1352
$this lock(bool|string $lock = true)

Enable lock.

Parameters

bool|string $lock TRUE for exclusive, FALSE for shared and string for custom

Return Value

$this

in Query at line 1364
$this sharedLock()

Enable shared lock.

Return Value

$this

in Query at line 1375
$this prefix(string $prefix)

Adds a query prefix.

Parameters

string $prefix Prefix

Return Value

$this

in Query at line 1388
protected mixed fetchFirst(mixed ...$fetchMode)

Executes a SELECT query and returns the first row of the result set or NULL if nothing is found.

Parameters

mixed ...$fetchMode Fetch mode

Return Value

mixed

in Relation at line 193
mixed first()

Returns a single record from the database.

Return Value

mixed

in Query at line 497
protected ResultSet createResultSet(array $results)

Creates a result set.

Parameters

array $results Results

Return Value

ResultSet

in Query at line 1423
protected array|ResultSet fetchAll(bool $returnResultSet, mixed ...$fetchMode)

Executes a SELECT query and returns an array containing all of the result set rows.

Parameters

bool $returnResultSet Return result set?
mixed ...$fetchMode Fetch mode

Return Value

array|ResultSet

in Relation at line 205
ResultSet all()

Returns a result set from the database.

Return Value

ResultSet

in Query at line 1448
mixed column(string $column = null)

Executes a SELECT query and returns the value of the chosen column of the first row of the result set.

Parameters

string $column The column to select

Return Value

mixed

in Query at line 1466
array columns(string $column = null)

Executes a SELECT query and returns an array containing the values of the indicated 0-indexed column.

Parameters

string $column The column to select

Return Value

array

in Query at line 1485
array pairs(string $key, string $value)

Executes a SELECT query and returns an array where the first column is used as keys and the second as values.

Parameters

string $key The column to use as keys
string $value The column to use as values

Return Value

array

in Query at line 1500
protected Generator fetchYield(mixed ...$fetchMode)

Executes a SELECT query and returns a generator that lets you iterate over the results.

Parameters

mixed ...$fetchMode Fetch mode

Return Value

Generator

in Query at line 524
Generator yield()

Returns a generator that lets you iterate over the results.

Return Value

Generator

in Query at line 1522
protected int paginationCount()

Returns the number of records that the query will return.

Return Value

int

in Query at line 38
ResultSet paginate($itemsPerPage = null, array $options = [])

Parameters

$itemsPerPage
array $options

Return Value

ResultSet

in Query at line 535
batch(Closure $processor, int $batchSize = 1000, int $offsetStart = 0, int|null $offsetEnd = null)

Fetches data in batches and passes them to the processor closure.

Parameters

Closure $processor Closure that processes the results
int $batchSize Batch size
int $offsetStart Offset start
int|null $offsetEnd Offset end

in Query at line 548
protected mixed aggregate(string $function, string|array $column)

Sets the selected column of the query to the chosen aggreate.

Executes the query and returns the result if not in subquery context.

Parameters

string $function Aggregate function
string|array $column Column name or array of column names

Return Value

mixed

in Query at line 1631
mixed min(string $column)

Returns the minimum value for the chosen column.

Parameters

string $column Column name

Return Value

mixed

in Query at line 1642
mixed max(string $column)

Returns the maximum value for the chosen column.

Parameters

string $column Column name

Return Value

mixed

in Query at line 1653
mixed sum(string $column)

Returns sum of all the values in the chosen column.

Parameters

string $column Column name

Return Value

mixed

in Query at line 1664
mixed avg(string $column)

Returns the average value for the chosen column.

Parameters

string $column Column name

Return Value

mixed

in Query at line 1675
int count(string $column = '*')

Returns the number of rows.

Parameters

string $column Column name

Return Value

int

in Query at line 1686
int countDistinct(string|array $column)

Returns the number of distinct values of the chosen column.

Parameters

string|array $column Column name or array of column names

Return Value

int

in Query at line 117
bool insert(array $values = [])

Inserts data into the chosen table.

Parameters

array $values Associative array of column values

Return Value

bool

in Query at line 1711
int|false insertAndGetId(array $values, string $primaryKey = 'id')

Inserts data into the chosen table and returns the auto increment id.

Parameters

array $values Associative array of column values
string $primaryKey Primary key

Return Value

int|false

in Query at line 145
int update(array $values)

Updates data from the chosen table.

Parameters

array $values Associative array of column values

Return Value

int

in Query at line 173
int increment(string $column, int $increment = 1)

Increments column value.

Parameters

string $column Column name
int $increment Increment value

Return Value

int

in Query at line 195
int decrement(string $column, int $decrement = 1)

Decrements column value.

Parameters

string $column Column name
int $decrement Decrement value

Return Value

int

in Query at line 217
int delete()

Deletes data from the chosen table.

Return Value

int

in Query at line 96
ORM getModel()

Returns the model.

Return Value

ORM

in Query at line 245
ORM|null get(int|string $id, array $columns = [])

Returns a record using the value of its primary key.

Parameters

int|string $id Primary key
array $columns Columns to select

Return Value

ORM|null

in Query at line 261
$this including(string|array|false $includes)

Adds relations to eager load.

Parameters

string|array|false $includes Relation or array of relations to eager load

Return Value

$this

in Query at line 303
$this excluding(string|array|true $excludes)

Removes relations to eager load.

Parameters

string|array|true $excludes Relation or array of relations to exclude from eager loading

Return Value

$this

in Query at line 338
protected array parseRelationCountName(string $relation)

Parses the count relation name and returns an array consisting of the relation name and the chosen alias.

Parameters

string $relation Relation name

Return Value

array

in Query at line 356
$this withCountOf(string|array $relations)

Adds subqueries that count the number of related records for the chosen relations.

Parameters

string|array $relations Relation or array of relations to count

Return Value

$this

in Query at line 393
protected ORM hydrateModel(array $result)

Returns a hydrated model.

Parameters

array $result Database result

Return Value

ORM

in Query at line 405
protected array parseIncludes()

Parses includes.

Return Value

array

in Query at line 442
protected loadIncludes(array $results)

Load includes.

Parameters

array $results Loaded records

in Query at line 460
protected array hydrateModelsAndLoadIncludes(mixed $results)

Returns hydrated models.

Parameters

mixed $results Database results

Return Value

array

in Query at line 566
$this scope(string $scope, mixed ...$arguments)

Calls a scope method on the model.

Parameters

string $scope Scope
mixed ...$arguments Arguments

Return Value

$this

in BelongsTo at line 25
protected string getForeignKey()

Returns the foreign key name.

Return Value

string

in BelongsTo at line 38
protected array keys(array $results)

Returns the keys used to eagerly load records.

Parameters

array $results Result set

Return Value

array

in BelongsTo at line 55
protected lazyCriterion()

Sets the criterion used when lazy loading related records.

in BelongsTo at line 63
protected $this eagerCriterion(array $keys)

Sets the criterion used when eager loading related records.

Parameters

array $keys Keys

Return Value

$this

in Relation at line 137
protected ResultSet eagerLoadChunked(array $keys)

Eager loads records in chunks.

Parameters

array $keys Keys

Return Value

ResultSet

in BelongsTo at line 73
protected $this getRelationCountQuery()

Returns a query instance used to build relation count subqueries.

Return Value

$this

in Relation at line 180
protected adjustQuery()

Adjusts the query.

in BelongsTo at line 88
eagerLoad(array $results, string $relation, Closure|null $criteria, array $includes)

Eager loads related records and matches them with their originating records.

Parameters

array $results &$results Originating records
string $relation Relation name
Closure|null $criteria Relation criteria
array $includes Includes passed from the originating record

in BelongsTo at line 120
ORM|null getRelated()

Returns related a record from the database.

Return Value

ORM|null