$tertiaryRelated
The related tertiary model instance.
protected
Model
$tertiaryRelated
= null
Enforce uniqueness for BelongsToManyUnique, MorphToManyUnique, and BelongsToManyThrough.
$tertiaryRelated | The related tertiary model instance. | \Illuminate\Database\Eloquent\Model |
---|---|---|
$tertiaryRelationName | The name to use for the tertiary relation (e.g. 'roles_via', etc). | string |
$tertiaryKey | The foreign key to the related tertiary model instance. | string |
$tertiaryCallback | A callback to apply to the tertiary query. | callable|null |
$limit | The limit to apply on the number of related models retrieved. | int|null |
$offset | The offset to apply on the related models retrieved. | int|null |
skip() | Alias to set the "offset" value of the query. | self |
offset() | Set the "offset" value of the query. | self |
take() | Alias to set the "limit" value of the query. | self |
limit() | Set the "limit" value of the query. | self |
withLimit() | Set the limit on the number of intermediate models to load. | $this |
withOffset() | Set the offset when loading the intermediate models. | $this |
withTertiary() | Add a query to load the nested tertiary models for this relationship. | self |
count() | Return the count of child models for this relationship. | int |
getRelationExistenceCountQuery() | Add the constraints for a relationship count query. | \Illuminate\Database\Eloquent\Builder |
match() | Match the eagerly loaded results to their parents. | array |
get() | Execute the query as a "select" statement, getting all requested models and matching up any tertiary models. | \Illuminate\Database\Eloquent\Collection |
getPaginatedQuery() | If we are applying either a limit or offset, we'll first determine a limited/offset list of model ids to select from in the final query. | \Illuminate\Database\Eloquent\Builder |
getEager() | Get the full join results for this query, overriding the default getEager() method. | \Illuminate\Database\Eloquent\Collection |
getModels() | Get the hydrated models and eager load their relations, optionally condensing the set of models before performing the eager loads. | \Illuminate\Database\Eloquent\Collection |
condenseModels() | Condense the raw join query results into a set of unique models. | array |
buildDictionary() | Build dictionary of related models keyed by the top-level "parent" id. | array |
buildTertiaryDictionary() | Build dictionary of tertiary models keyed by the corresponding related model keys. | array |
transferPivotsToTertiary() | Transfer the pivot to the tertiary model. | mixed |
getTertiaryModels() | Get the tertiary models for the relationship. | \Illuminate\Database\Eloquent\Collection |
matchTertiaryModels() | Match a collection of child models into a collection of parent models using a dictionary. | mixed |
unsetTertiaryPivots() | Unset tertiary pivots on a collection or array of models. | mixed |
The related tertiary model instance.
protected
Model
$tertiaryRelated
= null
The name to use for the tertiary relation (e.g. 'roles_via', etc).
protected
string
$tertiaryRelationName
= null
The foreign key to the related tertiary model instance.
protected
string
$tertiaryKey
A callback to apply to the tertiary query.
protected
callable|null
$tertiaryCallback
= null
The limit to apply on the number of related models retrieved.
protected
int|null
$limit
= null
The offset to apply on the related models retrieved.
protected
int|null
$offset
= null
Alias to set the "offset" value of the query.
public
skip(
$value :
int
)
: self
Set the "offset" value of the query.
public
offset(
$value :
int
)
: self
Alias to set the "limit" value of the query.
public
take(
$value :
int
)
: self
Set the "limit" value of the query.
public
limit(
$value :
int
)
: self
Set the limit on the number of intermediate models to load.
public
withLimit(
$value :
int
)
: $this
Set the offset when loading the intermediate models.
public
withOffset(
$value :
int
)
: $this
Add a query to load the nested tertiary models for this relationship.
public
withTertiary(
$tertiaryRelated :
string
[, $tertiaryRelationName :
string
= null ]
[, $tertiaryKey :
string
= null ]
[, $tertiaryCallback :
callable
= null ]
)
: self
Return the count of child models for this relationship.
public
count(
)
: int
Add the constraints for a relationship count query.
public
getRelationExistenceCountQuery(
$query :
Builder
, $parentQuery :
Builder
)
: Builder
Match the eagerly loaded results to their parents.
public
match(
$models :
array
, $results :
Collection
, $relation :
string
)
: array
Execute the query as a "select" statement, getting all requested models and matching up any tertiary models.
public
get(
[ $columns :
array
= ['*'] ]
)
: Collection
If we are applying either a limit or offset, we'll first determine a limited/offset list of model ids to select from in the final query.
public
getPaginatedQuery(
$query :
Builder
[, $limit :
int
= null ]
[, $offset :
int
= null ]
)
: Builder
Get the full join results for this query, overriding the default getEager() method.
public
getEager(
)
: Collection
The default getEager() method would normally just call get() on this relationship.
This is not what we want here though, because our get() method removes records before
match
has a chance to build out the substructures.
Get the hydrated models and eager load their relations, optionally condensing the set of models before performing the eager loads.
public
getModels(
[ $columns :
array
= ['*'] ]
[, $condenseModels :
bool
= true ]
)
: Collection
Condense the raw join query results into a set of unique models.
protected
condenseModels(
$models :
array
)
: array
Before doing this, we may optionally find any tertiary models that should be set as sub-relations on these models.
Build dictionary of related models keyed by the top-level "parent" id.
protected
buildDictionary(
$results :
Collection
[, $parentKey :
string
= null ]
)
: array
If there is a tertiary query set as well, then also build a two-level dictionary that maps parent ids to arrays of related ids, which in turn map to arrays of tertiary models corresponding to each relationship.
Build dictionary of tertiary models keyed by the corresponding related model keys.
protected
buildTertiaryDictionary(
$models :
array
)
: array
Transfer the pivot to the tertiary model.
protected
transferPivotsToTertiary(
$model :
Model
, $tertiaryModel :
Model
)
: mixed
Get the tertiary models for the relationship.
protected
getTertiaryModels(
$models :
array
)
: Collection
Match a collection of child models into a collection of parent models using a dictionary.
protected
matchTertiaryModels(
$dictionary :
array
, $results :
Collection
)
: mixed
Unset tertiary pivots on a collection or array of models.
protected
unsetTertiaryPivots(
$models :
Collection
)
: mixed