HasManyThrough
Extends
Uses
Properties
$firstKey string
The near key on the relationship.
$secondKey string
The far key on the relationship.
$localKey string
The local key on the relationship.
$secondLocalKey string
The local key on the intermediary model.
Methods
__construct ( Builder $query , Model $farParent , Model $throughParent , $firstKey , $secondKey , $localKey , $secondLocalKey ) : void
Create a new has many through relationship instance.
Parameters
addConstraints ( ) : void
Set the base constraints on the relation query.
performJoin ( Builder $query ) : void
Set the join clause on the query.
Parameters
- $query Builder |null
getQualifiedParentKeyName ( ) : string
Get the fully qualified parent key name.
throughParentSoftDeletes ( ) : bool
Determine whether "through" parent of the relation uses Soft Deletes.
withTrashedParents ( ) : $this
Indicate that trashed "through" parents should be included in the query.
addEagerConstraints ( array $models ) : void
Set the constraints for an eager load of the relation.
Parameters
- $models array
initRelation ( array $models , $relation ) : array
Initialize the relation on a set of models.
Parameters
- $models array
- $relation string
match ( array $models , Collection $results , $relation ) : array
Match the eagerly loaded results to their parents.
Parameters
- $models array
- $results Collection
- $relation string
buildDictionary ( Collection $results ) : array
Build model dictionary keyed by the relation's foreign key.
Parameters
- $results Collection
firstOrNew ( array $attributes ) : Model
Get the first related model record matching the attributes or instantiate it.
Parameters
- $attributes array
updateOrCreate ( array $attributes , array $values ) : Model
Create or update a related record matching the attributes, and fill it with values.
Parameters
- $attributes array
- $values array
firstWhere ( $column , $operator , $value , $boolean ) : Model |static
Add a basic where clause to the query, and return the first result.
Parameters
- $column Closure |string|array
- $operator mixed
- $value mixed
- $boolean string
first ( $columns ) : mixed
Execute the query and get the first related model.
Parameters
- $columns array
firstOrFail ( $columns ) : Model |static
Execute the query and get the first result or throw an exception.
Parameters
- $columns array
find ( $id , $columns ) : Model |Collection |null
Find a related model by its primary key.
Parameters
- $id mixed
- $columns array
findMany ( $ids , $columns ) : Collection
Find multiple related models by their primary keys.
Parameters
- $ids Arrayable |array
- $columns array
findOrFail ( $id , $columns ) : Model |Collection
Find a related model by its primary key or throw an exception.
Parameters
- $id mixed
- $columns array
getResults ( ) : mixed
Get the results of the relationship.
get ( $columns ) : Collection
Execute the query as a "select" statement.
Parameters
- $columns array
paginate ( $perPage , $columns , $pageName , $page ) : LengthAwarePaginator
Get a paginator for the "select" statement.
Parameters
- $perPage int|null
- $columns array
- $pageName string
- $page int
simplePaginate ( $perPage , $columns , $pageName , $page ) : Paginator
Paginate the given query into a simple paginator.
Parameters
- $perPage int|null
- $columns array
- $pageName string
- $page int|null
cursorPaginate ( $perPage , $columns , $cursorName , $cursor ) : CursorPaginator
Paginate the given query into a cursor paginator.
Parameters
- $perPage int|null
- $columns array
- $cursorName string
- $cursor string|null
shouldSelect ( array $columns ) : array
Set the select clause for the relation query.
Parameters
- $columns array
chunk ( $count , callable $callback ) : bool
Chunk the results of the query.
Parameters
- $count int
- $callback callable
chunkById ( $count , callable $callback , $column , $alias ) : bool
Chunk the results of a query by comparing numeric IDs.
Parameters
- $count int
- $callback callable
- $column string|null
- $alias string|null
each ( callable $callback , $count ) : bool
Execute a callback over each item while chunking.
Parameters
- $callback callable
- $count int
lazy ( $chunkSize ) : LazyCollection
Query lazily, by chunks of the given size.
Parameters
- $chunkSize int
lazyById ( $chunkSize , $column , $alias ) : LazyCollection
Query lazily, by chunking the results of a query by comparing IDs.
Parameters
- $chunkSize int
- $column string|null
- $alias string|null
prepareQueryBuilder ( $columns ) : Builder
Prepare the query builder for query execution.
Parameters
- $columns array
getRelationExistenceQuery ( Builder $query , Builder $parentQuery , $columns ) : Builder
Add the constraints for a relationship query.
Parameters
getRelationExistenceQueryForSelfRelation ( Builder $query , Builder $parentQuery , $columns ) : Builder
Add the constraints for a relationship query on the same table.
Parameters
getRelationExistenceQueryForThroughSelfRelation ( Builder $query , Builder $parentQuery , $columns ) : Builder
Add the constraints for a relationship query on the same table as the through parent.
Parameters
getQualifiedFarKeyName ( ) : string
Get the qualified foreign key on the related model.
getFirstKeyName ( ) : string
Get the foreign key on the "through" model.
getQualifiedFirstKeyName ( ) : string
Get the qualified foreign key on the "through" model.
getForeignKeyName ( ) : string
Get the foreign key on the related model.
getQualifiedForeignKeyName ( ) : string
Get the qualified foreign key on the related model.
getLocalKeyName ( ) : string
Get the local key on the far parent model.
getQualifiedLocalKeyName ( ) : string
Get the qualified local key on the far parent model.
getSecondLocalKeyName ( ) : string
Get the local key on the intermediary model.