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 $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 $paginationFactory Pagination factory. from Query
protected ORM $model Instance of the model to hydrate. from Query
protected ORM $parent Parent record. from Relation
protected string $foreignKey Foreign key. from Relation
protected bool $lazy Lazy load related records? from Relation

Methods

__construct(Connection $connection, ORM $parent, ORM $related, string $polymorphicType)

Constructor.

__clone()

Create a fresh compiler instance when we clone the query.

from Query
newInstance()

Returns a new query builder instance.

from Query
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
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
setOperation(Closure|Query|Subquery $query, string $operation)

Adds a set operation.

from Query
union(Closure|Query|Subquery $query)

Adds a UNION operation.

from Query
unionAll(Closure|Query|Subquery $query)

Adds a UNION ALL operation.

from Query
intersect(Closure|Query|Subquery $query)

Adds a INTERSECT operation.

from Query
intersectAll(Closure|Query|Subquery $query)

Adds a INTERSECT ALL operation.

from Query
except(Closure|Query|Subquery $query)

Adds a EXCEPT operation.

from Query
exceptAll(Closure|Query|Subquery $query)

Adds a EXCEPT ALL operation.

from Query
table(string|Closure|Subquery|Raw $table)

Sets table we want to query.

from Query
from(string|Closure|Subquery|Raw $table)

Alias of Query::table().

from Query
into(string|Closure|Subquery|Raw $table)

Alias of Query::table().

from Query
select(array $columns)

Sets the columns we want to select.

from Query
distinct()

Select distinct?

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

Adds a WHERE clause.

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

Adds a raw WHERE clause.

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

Adds a OR WHERE clause.

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

Adds a raw OR WHERE clause.

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

Adds a BETWEEN clause.

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

Adds a OR BETWEEN clause.

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

Adds a NOT BETWEEN clause.

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

Adds a OR NOT BETWEEN clause.

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

Adds a IN clause.

from Query
orIn(string $column, mixed $values)

Adds a OR IN clause.

from Query
notIn(string $column, mixed $values)

Adds a NOT IN clause.

from Query
orNotIn(string $column, mixed $values)

Adds a OR NOT IN clause.

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

Adds a IS NULL clause.

from Query
orIsNull(mixed $column)

Adds a OR IS NULL clause.

from Query
isNotNull(mixed $column)

Adds a IS NOT NULL clause.

from Query
orIsNotNull(mixed $column)

Adds a OR IS NOT NULL clause.

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

Adds a EXISTS clause.

from Query
orExists(Closure|Subquery $query)

Adds a OR EXISTS clause.

from Query
notExists(Closure|Subquery $query)

Adds a NOT EXISTS clause.

from Query
orNotExists(Closure|Subquery $query)

Adds a OR NOT EXISTS clause.

from Query
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
joinRaw(string $table, string $column1, string $operator, string $raw, string $type = 'INNER')

Adds a raw JOIN clause.

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

Adds a LEFT OUTER JOIN clause.

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

Adds a raw LEFT OUTER JOIN clause.

from Query
groupBy(string|array $columns)

Adds a GROUP BY clause.

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

Adds a HAVING clause.

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

Adds a raw HAVING clause.

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

Adds a OR HAVING clause.

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

Adds a raw OR HAVING clause.

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

Adds a ORDER BY clause.

from Query
orderByRaw(string $raw, string $order = 'ASC')

Adds a raw ORDER BY clause.

from Query
ascending(string|array $columns)

Adds an ascending ORDER BY clause.

from Query
ascendingRaw(string $raw)

Adds a raw ascending ORDER BY clause.

from Query
descending(string|array $columns)

Adds a descending ORDER BY clause.

from Query
descendingRaw(string $raw)

Adds a raw descending ORDER BY clause.

from Query
clearOrderings()

Clears the ordering clauses.

from Query
limit(int $limit)

Adds a LIMIT clause.

from Query
offset(int $offset)

Adds a OFFSET clause.

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

Enable lock.

from Query
sharedLock()

Enable shared lock.

from Query
prefix(string $prefix)

Adds a query prefix.

from Query
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
mixed
fetchFirst(mixed ...$fetchMode)

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

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
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 $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
int
min(string $column)

Returns the minimum value for the chosen column.

from Query
int
max(string $column)

Returns the maximum value for the chosen column.

from Query
int
sum(string $column)

Returns sum of all the values in the chosen column.

from Query
float
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|bool
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
get(int $id, array $columns = [])

Returns a record using the value of its primary key.

from Query
including(string|array|bool $includes)

Adds relations to eager load.

from Query
excluding(string|array|bool $excludes)

Removes relations to eager load.

from Query
ORM
hydrateModel(object $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
__call(string $name, array $arguments)

Magic method that allows us to call model scopes.

from Query
string
getForeignKey()

Returns the foreign key.

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
eagerCriterion(array $keys)

Sets the criterion used when eager loading related records.

from BelongsTo
eagerLoadChunked(array $keys)

Eager loads records in chunks.

from Relation
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 parent records.

from BelongsTo
ORM|false
getRelated()

Returns related a record from the database.

from BelongsTo

Details

at line 28
__construct(Connection $connection, ORM $parent, ORM $related, string $polymorphicType)

Constructor.

Parameters

Connection $connection Database connection
ORM $parent Parent model
ORM $related Related model
string $polymorphicType Polymorphic type

in Query at line 169
__clone()

Create a fresh compiler instance when we clone the query.

in Query at line 179
Query newInstance()

Returns a new query builder instance.

Return Value

Query

in Query at line 189
Query inSubqueryContext()

Sets the query to subquery context.

Return Value

Query

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

Sets the pagination factory.

Parameters

PaginationFactoryInterface|Closure $factory Pagination factory

in Query at line 211
static PaginationFactoryInterface getPaginationFactory()

Gets the pagination factory.

in Query at line 228
Connection getConnection()

Returns the connection instance.

Return Value

Connection

in Query at line 238
Compiler getCompiler()

Returns query compiler instance.

Return Value

Compiler

in Query at line 248
array getSetOperations()

Returns the set operations.

Return Value

array

in Query at line 258
mixed getTable()

Returns the database table.

Return Value

mixed

in Query at line 268
bool isDistinct()

Is it a distict select?

Return Value

bool

in Query at line 278
array getColumns()

Returns the columns from which we are fetching data.

Return Value

array

in Query at line 288
array getWheres()

Returns WHERE clauses.

Return Value

array

in Query at line 298
array getJoins()

Returns JOIN clauses.

Return Value

array

in Query at line 308
array getGroupings()

Returns GROUP BY clauses.

Return Value

array

in Query at line 318
array getHavings()

Returns HAVING clauses.

Return Value

array

in Query at line 328
array getOrderings()

Returns ORDER BY clauses.

Return Value

array

in Query at line 338
int|null getLimit()

Returns the limit.

Return Value

int|null

in Query at line 348
int|null getOffset()

Returns the offset.

Return Value

int|null

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

Returns the lock.

Return Value

bool|string|null

in Query at line 368
string|null getPrefix()

Returns the prefix.

Return Value

string|null

in Query at line 380
protected Query setOperation(Closure|Query|Subquery $query, string $operation)

Adds a set operation.

Parameters

Closure|Query|Subquery $query Query
string $operation Operation

Return Value

Query

in Query at line 402
Query union(Closure|Query|Subquery $query)

Adds a UNION operation.

Parameters

Closure|Query|Subquery $query Query

Return Value

Query

in Query at line 413
Query unionAll(Closure|Query|Subquery $query)

Adds a UNION ALL operation.

Parameters

Closure|Query|Subquery $query Query

Return Value

Query

in Query at line 424
Query intersect(Closure|Query|Subquery $query)

Adds a INTERSECT operation.

Parameters

Closure|Query|Subquery $query Query

Return Value

Query

in Query at line 435
Query intersectAll(Closure|Query|Subquery $query)

Adds a INTERSECT ALL operation.

Parameters

Closure|Query|Subquery $query Query

Return Value

Query

in Query at line 446
Query except(Closure|Query|Subquery $query)

Adds a EXCEPT operation.

Parameters

Closure|Query|Subquery $query Query

Return Value

Query

in Query at line 457
Query exceptAll(Closure|Query|Subquery $query)

Adds a EXCEPT ALL operation.

Parameters

Closure|Query|Subquery $query Query

Return Value

Query

in Query at line 468
Query table(string|Closure|Subquery|Raw $table)

Sets table we want to query.

Parameters

string|Closure|Subquery|Raw $table Database table or subquery

Return Value

Query

in Query at line 486
Query from(string|Closure|Subquery|Raw $table)

Alias of Query::table().

Parameters

string|Closure|Subquery|Raw $table Database table or subquery

Return Value

Query

in Query at line 497
Query into(string|Closure|Subquery|Raw $table)

Alias of Query::table().

Parameters

string|Closure|Subquery|Raw $table Database table or subquery

Return Value

Query

in Query at line 508
Query select(array $columns)

Sets the columns we want to select.

Parameters

array $columns Array of columns we want to select from

Return Value

Query

in Query at line 520
Query distinct()

Select distinct?

Return Value

Query

in Query at line 536
Query 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

Query

in Query at line 575
Query 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

Query

in Query at line 600
Query 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

Query

in Query at line 613
Query 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

Query

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

Adds a BETWEEN clause.

Parameters

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

Return Value

Query

in Query at line 651
Query orBetween(string $column, mixed $value1, mixed $value2)

Adds a OR BETWEEN clause.

Parameters

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

Return Value

Query

in Query at line 664
Query notBetween(string $column, mixed $value1, mixed $value2)

Adds a NOT BETWEEN clause.

Parameters

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

Return Value

Query

in Query at line 677
Query orNotBetween(string $column, mixed $value1, mixed $value2)

Adds a OR NOT BETWEEN clause.

Parameters

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

Return Value

Query

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

Adds a IN clause.

Parameters

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

Return Value

Query

in Query at line 721
Query orIn(string $column, mixed $values)

Adds a OR IN clause.

Parameters

string $column Column name
mixed $values Array of values or Subquery

Return Value

Query

in Query at line 733
Query notIn(string $column, mixed $values)

Adds a NOT IN clause.

Parameters

string $column Column name
mixed $values Array of values or Subquery

Return Value

Query

in Query at line 745
Query orNotIn(string $column, mixed $values)

Adds a OR NOT IN clause.

Parameters

string $column Column name
mixed $values Array of values or Subquery

Return Value

Query

in Query at line 758
Query 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

Query

in Query at line 777
Query orIsNull(mixed $column)

Adds a OR IS NULL clause.

Parameters

mixed $column Column name

Return Value

Query

in Query at line 788
Query isNotNull(mixed $column)

Adds a IS NOT NULL clause.

Parameters

mixed $column Column name

Return Value

Query

in Query at line 799
Query orIsNotNull(mixed $column)

Adds a OR IS NOT NULL clause.

Parameters

mixed $column Column name

Return Value

Query

in Query at line 812
Query exists(Closure|Subquery $query, string $separator = 'AND', bool $not = false)

Adds a EXISTS clause.

Parameters

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

Return Value

Query

in Query at line 836
Query orExists(Closure|Subquery $query)

Adds a OR EXISTS clause.

Parameters

Closure|Subquery $query Subquery

Return Value

Query

in Query at line 847
Query notExists(Closure|Subquery $query)

Adds a NOT EXISTS clause.

Parameters

Closure|Subquery $query Subquery

Return Value

Query

in Query at line 858
Query orNotExists(Closure|Subquery $query)

Adds a OR NOT EXISTS clause.

Parameters

Closure|Subquery $query Subquery

Return Value

Query

in Query at line 73
Query 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

Query

in Query at line 909
Query 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

Query

in Query at line 923
Query 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

Query

in Query at line 937
Query 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

Query

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

Adds a GROUP BY clause.

Parameters

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

Return Value

Query

in Query at line 964
Query 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

Query

in Query at line 986
Query 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

Query

in Query at line 999
Query 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

Query

in Query at line 1012
Query 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

Query

in Query at line 1024
Query 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

Query

in Query at line 1042
Query orderByRaw(string $raw, string $order = 'ASC')

Adds a raw ORDER BY clause.

Parameters

string $raw Raw SQL
string $order Sorting order

Return Value

Query

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

Adds an ascending ORDER BY clause.

Parameters

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

Return Value

Query

in Query at line 1064
Query ascendingRaw(string $raw)

Adds a raw ascending ORDER BY clause.

Parameters

string $raw Raw SQL

Return Value

Query

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

Adds a descending ORDER BY clause.

Parameters

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

Return Value

Query

in Query at line 1086
Query descendingRaw(string $raw)

Adds a raw descending ORDER BY clause.

Parameters

string $raw Raw SQL

Return Value

Query

in Query at line 1096
Query clearOrderings()

Clears the ordering clauses.

Return Value

Query

in Query at line 1109
Query limit(int $limit)

Adds a LIMIT clause.

Parameters

int $limit Limit

Return Value

Query

in Query at line 1122
Query offset(int $offset)

Adds a OFFSET clause.

Parameters

int $offset Offset

Return Value

Query

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

Enable lock.

Parameters

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

Return Value

Query

in Query at line 1147
Query sharedLock()

Enable shared lock.

Return Value

Query

in Query at line 1158
Query prefix(string $prefix)

Adds a query prefix.

Parameters

string $prefix Prefix

Return Value

Query

in Query at line 1171
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 1189
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 1208
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 1223
protected mixed fetchFirst(mixed ...$fetchMode)

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

Parameters

mixed ...$fetchMode Fetch mode

Return Value

mixed

in Relation at line 171
mixed first()

Returns a single record from the database.

Return Value

mixed

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

Creates a result set.

Parameters

array $results Results

Return Value

ResultSet

in Query at line 1258
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 183
ResultSet all()

Returns a result set from the database.

Return Value

ResultSet

in Query at line 1283
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 438
Generator yield()

Returns a generator that lets you iterate over the results.

Return Value

Generator

in Query at line 1305
protected int paginationCount()

Returns the number of records that the query will return.

Return Value

int

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

Parameters

$itemsPerPage
array $options

Return Value

ResultSet

in Query at line 449
batch(Closure $processor, int $batchSize = 1000, int $offsetStart = 0, int $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 $offsetEnd Offset end

in Query at line 1393
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 1411
int min(string $column)

Returns the minimum value for the chosen column.

Parameters

string $column Column name

Return Value

int

in Query at line 1422
int max(string $column)

Returns the maximum value for the chosen column.

Parameters

string $column Column name

Return Value

int

in Query at line 1433
int sum(string $column)

Returns sum of all the values in the chosen column.

Parameters

string $column Column name

Return Value

int

in Query at line 1444
float avg(string $column)

Returns the average value for the chosen column.

Parameters

string $column Column name

Return Value

float

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

Returns the number of rows.

Parameters

string $column Column name

Return Value

int

in Query at line 1466
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 86
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 1491
int|bool 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|bool

in Query at line 114
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 142
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 164
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 186
int delete()

Deletes data from the chosen table.

Return Value

int

in Query at line 65
ORM getModel()

Returns the model.

Return Value

ORM

in Query at line 214
ORM get(int $id, array $columns = [])

Returns a record using the value of its primary key.

Parameters

int $id Primary key
array $columns Columns to select

Return Value

ORM

in Query at line 230
Query including(string|array|bool $includes)

Adds relations to eager load.

Parameters

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

Return Value

Query

in Query at line 272
Query excluding(string|array|bool $excludes)

Removes relations to eager load.

Parameters

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

Return Value

Query

in Query at line 307
protected ORM hydrateModel(object $result)

Returns a hydrated model.

Parameters

object $result Database result

Return Value

ORM

in Query at line 319
protected array parseIncludes()

Parses includes.

Return Value

array

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

Load includes.

Parameters

array $results Loaded records

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

Returns hydrated models.

Parameters

mixed $results Database results

Return Value

array

in Query at line 466
Query __call(string $name, array $arguments)

Magic method that allows us to call model scopes.

Parameters

string $name Method name
array $arguments Method arguments

Return Value

Query

in BelongsTo at line 23
protected string getForeignKey()

Returns the foreign key.

Return Value

string

in BelongsTo at line 36
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 53
protected lazyCriterion()

Sets the criterion used when lazy loading related records.

in BelongsTo at line 64
protected Relation eagerCriterion(array $keys)

Sets the criterion used when eager loading related records.

Parameters

array $keys Parent keys

Return Value

Relation

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

Eager loads records in chunks.

Parameters

array $keys Parent keys

Return Value

ResultSet

in Relation at line 158
protected adjustQuery()

Adjusts the query.

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

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

Parameters

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

in BelongsTo at line 113
ORM|false getRelated()

Returns related a record from the database.

Return Value

ORM|false