Documentation

HasManyThrough extends HasManyThrough
in package
Uses DefinedConstraints

Table of Contents

$morphMap  : array<string|int, mixed>
An array to map class names to their morph names in database.
$constraints  : bool
Indicates if the relation is adding constraints.
$farParent  : Model
The far parent model instance.
$firstKey  : string
The near key on the relationship.
$localKey  : string
The local key on the relationship.
$macros  : array<string|int, mixed>
The registered string macros.
$parent  : Model
The parent model instance.
$query  : Builder
The Eloquent query builder instance.
$related  : Model
The related model instance.
$relationName  : string
$secondKey  : string
The far key on the relationship.
$secondLocalKey  : string
The local key on the intermediary model.
$selfJoinCount  : int
The count of self joins.
$throughParent  : Model
The "through" parent model instance.
__call()  : mixed
Dynamically handle calls to the class.
__callStatic()  : mixed
Dynamically handle calls to the class.
__clone()  : void
Force a clone of the underlying query builder when cloning.
__construct()  : void
Create a new has many relationship instance.
addConstraints()  : void
Set the base constraints on the relation query.
addDefinedConstraints()  : void
Set the defined constraints on the relation query.
addDefinedConstraintsToQuery()  : mixed
Add query based constraints.
addDefinedConstraintsToRelation()  : mixed
Add relation based constraints.
addEagerConstraints()  : void
Set the constraints for an eager load of the relation.
createdAt()  : string
Get the name of the "created at" column.
find()  : Model|Collection|null
Find a related model by its primary key.
findMany()  : Collection
Find multiple related models by their primary keys.
findOrFail()  : Model|Collection
Find a related model by its primary key or throw an exception.
first()  : mixed
Execute the query and get the first related model.
firstOrFail()  : Model|static
Execute the query and get the first result or throw an exception.
firstOrNew()  : Model
Get the first related model record matching the attributes or instantiate it.
get()  : Collection
Execute the query as a "select" statement.
getBaseQuery()  : Builder
Get the base query builder driving the Eloquent builder.
getEager()  : Collection
Get the relationship for eager loading.
getMorphedModel()  : string|null
Get the model associated with a custom polymorphic type.
getParent()  : Model
Get the parent model of the relation.
getQualifiedFarKeyName()  : string
Get the qualified foreign key on the related model.
getQualifiedFirstKeyName()  : string
Get the qualified foreign key on the "through" model.
getQualifiedForeignKeyName()  : string
Get the qualified foreign key on the related model.
getQualifiedLocalKeyName()  : string
Get the qualified local key on the far parent model.
getQualifiedParentKeyName()  : string
Get the fully qualified parent key name.
getQuery()  : Builder
Get the underlying query for the relation.
getRelated()  : Model
Get the related model of the relation.
getRelationCountHash()  : string
Get a relationship join table hash.
getRelationExistenceCountQuery()  : Builder
Add the constraints for a relationship count query.
getRelationExistenceQuery()  : Builder
Add the constraints for an internal relationship existence query.
getRelationExistenceQueryForSelfRelation()  : Builder
Add the constraints for a relationship query on the same table.
getResults()  : mixed
Get the results of the relationship.
hasMacro()  : bool
Checks if macro is registered.
initRelation()  : array<string|int, mixed>
Initialize the relation on a set of models.
macro()  : void
Register a custom macro.
match()  : array<string|int, mixed>
Match the eagerly loaded results to their parents.
mixin()  : void
Mix another object into the class.
morphMap()  : array<string|int, mixed>
Set or get the morph map for polymorphic relations.
noConstraints()  : mixed
Run a callback with constraints disabled on the relation.
paginate()  : LengthAwarePaginator
Get a paginator for the "select" statement.
parentSoftDeletes()  : bool
Determine whether close parent of the relation uses Soft Deletes.
rawUpdate()  : int
Run a raw update against the base query.
relatedUpdatedAt()  : string
Get the name of the related model's "updated at" column.
simplePaginate()  : Paginator
Paginate the given query into a simple paginator.
throughParentSoftDeletes()  : bool
Determine whether "through" parent of the relation uses Soft Deletes.
touch()  : void
Touch all of the related models for the relationship.
updatedAt()  : string
Get the name of the "updated at" column.
updateOrCreate()  : Model
Create or update a related record matching the attributes, and fill it with values.
buildDictionary()  : array<string|int, mixed>
Build model dictionary keyed by the relation's foreign key.
buildMorphMapFromModels()  : array<string|int, mixed>|null
Builds a table-keyed array from model class names.
getKeys()  : array<string|int, mixed>
Get all of the primary keys for an array of models.
performJoin()  : void
Set the join clause on the query.
shouldSelect()  : array<string|int, mixed>
Set the select clause for the relation query.

Properties

$morphMap

An array to map class names to their morph names in database.

public static array<string|int, mixed> $morphMap = []

$constraints

Indicates if the relation is adding constraints.

protected static bool $constraints = true

$firstKey

The near key on the relationship.

protected string $firstKey

$localKey

The local key on the relationship.

protected string $localKey

$macros

The registered string macros.

protected static array<string|int, mixed> $macros = []

$relationName

protected string $relationName

The "name" of the relationship.

$secondKey

The far key on the relationship.

protected string $secondKey

$secondLocalKey

The local key on the intermediary model.

protected string $secondLocalKey

$selfJoinCount

The count of self joins.

protected static int $selfJoinCount = 0

Methods

__call()

Dynamically handle calls to the class.

public __call(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
$method : string
$parameters : array<string|int, mixed>
Tags
throws
BadMethodCallException
Return values
mixed

__callStatic()

Dynamically handle calls to the class.

public static __callStatic(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
$method : string
$parameters : array<string|int, mixed>
Tags
throws
BadMethodCallException
Return values
mixed

__clone()

Force a clone of the underlying query builder when cloning.

public __clone() : void
Return values
void

__construct()

Create a new has many relationship instance.

public __construct(Builder $query, Model $farParent, Model $parent, mixed $firstKey, mixed $secondKey, mixed $localKey, mixed $secondLocalKey[, mixed $relationName = null ]) : void
Parameters
$query : Builder
$farParent : Model
$parent : Model
$firstKey : mixed
$secondKey : mixed
$localKey : mixed
$secondLocalKey : mixed
$relationName : mixed = null
Return values
void

addConstraints()

Set the base constraints on the relation query.

public abstract addConstraints() : void
Return values
void

addDefinedConstraints()

Set the defined constraints on the relation query.

public addDefinedConstraints() : void
Return values
void

addDefinedConstraintsToQuery()

Add query based constraints.

public addDefinedConstraintsToQuery(QueryBuilder $query[, array<string|int, mixed> $args = null ]) : mixed
Parameters
$query : QueryBuilder
$args : array<string|int, mixed> = null
Return values
mixed

addDefinedConstraintsToRelation()

Add relation based constraints.

public addDefinedConstraintsToRelation(Relation $relation[, array<string|int, mixed> $args = null ]) : mixed
Parameters
$relation : Relation
$args : array<string|int, mixed> = null
Return values
mixed

addEagerConstraints()

Set the constraints for an eager load of the relation.

public abstract addEagerConstraints(array<string|int, mixed> $models) : void
Parameters
$models : array<string|int, mixed>
Return values
void

createdAt()

Get the name of the "created at" column.

public createdAt() : string
Return values
string

find()

Find a related model by its primary key.

public find(mixed $id[, array<string|int, mixed> $columns = ['*'] ]) : Model|Collection|null
Parameters
$id : mixed
$columns : array<string|int, mixed> = ['*']
Return values
Model|Collection|null

findMany()

Find multiple related models by their primary keys.

public findMany(mixed $ids[, array<string|int, mixed> $columns = ['*'] ]) : Collection
Parameters
$ids : mixed
$columns : array<string|int, mixed> = ['*']
Return values
Collection

first()

Execute the query and get the first related model.

public first([array<string|int, mixed> $columns = ['*'] ]) : mixed
Parameters
$columns : array<string|int, mixed> = ['*']
Return values
mixed

firstOrFail()

Execute the query and get the first result or throw an exception.

public firstOrFail([array<string|int, mixed> $columns = ['*'] ]) : Model|static
Parameters
$columns : array<string|int, mixed> = ['*']
Tags
throws
ModelNotFoundException
Return values
Model|static

firstOrNew()

Get the first related model record matching the attributes or instantiate it.

public firstOrNew(array<string|int, mixed> $attributes) : Model
Parameters
$attributes : array<string|int, mixed>
Return values
Model

get()

Execute the query as a "select" statement.

public get([array<string|int, mixed> $columns = ['*'] ]) : Collection
Parameters
$columns : array<string|int, mixed> = ['*']
Return values
Collection

getBaseQuery()

Get the base query builder driving the Eloquent builder.

public getBaseQuery() : Builder
Return values
Builder

getMorphedModel()

Get the model associated with a custom polymorphic type.

public static getMorphedModel(string $alias) : string|null
Parameters
$alias : string
Return values
string|null

getParent()

Get the parent model of the relation.

public getParent() : Model
Return values
Model

getQualifiedFarKeyName()

Get the qualified foreign key on the related model.

public getQualifiedFarKeyName() : string
Return values
string

getQualifiedFirstKeyName()

Get the qualified foreign key on the "through" model.

public getQualifiedFirstKeyName() : string
Return values
string

getQualifiedForeignKeyName()

Get the qualified foreign key on the related model.

public getQualifiedForeignKeyName() : string
Return values
string

getQualifiedLocalKeyName()

Get the qualified local key on the far parent model.

public getQualifiedLocalKeyName() : string
Return values
string

getQualifiedParentKeyName()

Get the fully qualified parent key name.

public getQualifiedParentKeyName() : string
Return values
string

getRelated()

Get the related model of the relation.

public getRelated() : Model
Return values
Model

getRelationCountHash()

Get a relationship join table hash.

public getRelationCountHash() : string
Return values
string

getRelationExistenceCountQuery()

Add the constraints for a relationship count query.

public getRelationExistenceCountQuery(Builder $query, Builder $parentQuery) : Builder
Parameters
$query : Builder
$parentQuery : Builder
Return values
Builder

getRelationExistenceQuery()

Add the constraints for an internal relationship existence query.

public getRelationExistenceQuery(Builder $query, Builder $parentQuery[, array<string|int, mixed>|mixed $columns = ['*'] ]) : Builder

Essentially, these queries compare on column names like whereColumn.

Parameters
$query : Builder
$parentQuery : Builder
$columns : array<string|int, mixed>|mixed = ['*']
Return values
Builder

getRelationExistenceQueryForSelfRelation()

Add the constraints for a relationship query on the same table.

public getRelationExistenceQueryForSelfRelation(Builder $query, Builder $parentQuery[, array<string|int, mixed>|mixed $columns = ['*'] ]) : Builder
Parameters
$query : Builder
$parentQuery : Builder
$columns : array<string|int, mixed>|mixed = ['*']
Return values
Builder

getResults()

Get the results of the relationship.

public abstract getResults() : mixed
Return values
mixed

hasMacro()

Checks if macro is registered.

public static hasMacro(string $name) : bool
Parameters
$name : string
Return values
bool

initRelation()

Initialize the relation on a set of models.

public abstract initRelation(array<string|int, mixed> $models, string $relation) : array<string|int, mixed>
Parameters
$models : array<string|int, mixed>
$relation : string
Return values
array<string|int, mixed>

macro()

Register a custom macro.

public static macro(string $name, object|callable $macro) : void
Parameters
$name : string
$macro : object|callable
Return values
void

match()

Match the eagerly loaded results to their parents.

public abstract match(array<string|int, mixed> $models, Collection $results, string $relation) : array<string|int, mixed>
Parameters
$models : array<string|int, mixed>
$results : Collection
$relation : string
Return values
array<string|int, mixed>

mixin()

Mix another object into the class.

public static mixin(object $mixin) : void
Parameters
$mixin : object
Return values
void

morphMap()

Set or get the morph map for polymorphic relations.

public static morphMap([array<string|int, mixed>|null $map = null ][, bool $merge = true ]) : array<string|int, mixed>
Parameters
$map : array<string|int, mixed>|null = null
$merge : bool = true
Return values
array<string|int, mixed>

noConstraints()

Run a callback with constraints disabled on the relation.

public static noConstraints(Closure $callback) : mixed
Parameters
$callback : Closure
Return values
mixed

paginate()

Get a paginator for the "select" statement.

public paginate([int $perPage = null ][, array<string|int, mixed> $columns = ['*'] ][, string $pageName = 'page' ][, int $page = null ]) : LengthAwarePaginator
Parameters
$perPage : int = null
$columns : array<string|int, mixed> = ['*']
$pageName : string = 'page'
$page : int = null
Return values
LengthAwarePaginator

parentSoftDeletes()

Determine whether close parent of the relation uses Soft Deletes.

public parentSoftDeletes() : bool
Return values
bool

rawUpdate()

Run a raw update against the base query.

public rawUpdate([array<string|int, mixed> $attributes = [] ]) : int
Parameters
$attributes : array<string|int, mixed> = []
Return values
int

relatedUpdatedAt()

Get the name of the related model's "updated at" column.

public relatedUpdatedAt() : string
Return values
string

simplePaginate()

Paginate the given query into a simple paginator.

public simplePaginate([int $perPage = null ][, array<string|int, mixed> $columns = ['*'] ][, string $pageName = 'page' ][, int|null $page = null ]) : Paginator
Parameters
$perPage : int = null
$columns : array<string|int, mixed> = ['*']
$pageName : string = 'page'
$page : int|null = null
Return values
Paginator

throughParentSoftDeletes()

Determine whether "through" parent of the relation uses Soft Deletes.

public throughParentSoftDeletes() : bool
Return values
bool

touch()

Touch all of the related models for the relationship.

public touch() : void
Return values
void

updatedAt()

Get the name of the "updated at" column.

public updatedAt() : string
Return values
string

updateOrCreate()

Create or update a related record matching the attributes, and fill it with values.

public updateOrCreate(array<string|int, mixed> $attributes[, array<string|int, mixed> $values = [] ]) : Model
Parameters
$attributes : array<string|int, mixed>
$values : array<string|int, mixed> = []
Return values
Model

buildDictionary()

Build model dictionary keyed by the relation's foreign key.

protected buildDictionary(Collection $results) : array<string|int, mixed>
Parameters
$results : Collection
Return values
array<string|int, mixed>

buildMorphMapFromModels()

Builds a table-keyed array from model class names.

protected static buildMorphMapFromModels([array<string|int, string>|null $models = null ]) : array<string|int, mixed>|null
Parameters
$models : array<string|int, string>|null = null
Return values
array<string|int, mixed>|null

getKeys()

Get all of the primary keys for an array of models.

protected getKeys(array<string|int, mixed> $models[, string $key = null ]) : array<string|int, mixed>
Parameters
$models : array<string|int, mixed>
$key : string = null
Return values
array<string|int, mixed>

performJoin()

Set the join clause on the query.

protected performJoin([Builder|null $query = null ]) : void
Parameters
$query : Builder|null = null
Return values
void

shouldSelect()

Set the select clause for the relation query.

protected shouldSelect([array<string|int, mixed> $columns = ['*'] ]) : array<string|int, mixed>
Parameters
$columns : array<string|int, mixed> = ['*']
Return values
array<string|int, mixed>

Search results