QueriesRelationships
Methods
has ( $relation , $operator , $count , $boolean , Closure $callback ) : Builder |static
Add a relationship count / exists condition to the query.
Parameters
hasNested ( $relations , $operator , $count , $boolean , $callback ) : Builder |static
Add nested relationship count / exists conditions to the query.
Parameters
- $relations string
- $operator string
- $count int
- $boolean string
- $callback Closure |null
orHas ( $relation , $operator , $count ) : Builder |static
Add a relationship count / exists condition to the query with an "or".
Parameters
- $relation string
- $operator string
- $count int
doesntHave ( $relation , $boolean , Closure $callback ) : Builder |static
Add a relationship count / exists condition to the query.
Parameters
- $relation string
- $boolean string
- $callback Closure |null
orDoesntHave ( $relation ) : Builder |static
Add a relationship count / exists condition to the query with an "or".
Parameters
- $relation string
whereHas ( $relation , Closure $callback , $operator , $count ) : Builder |static
Add a relationship count / exists condition to the query with where clauses.
Parameters
- $relation string
- $callback Closure |null
- $operator string
- $count int
orWhereHas ( $relation , Closure $callback , $operator , $count ) : Builder |static
Add a relationship count / exists condition to the query with where clauses and an "or".
Parameters
- $relation string
- $callback Closure |null
- $operator string
- $count int
whereDoesntHave ( $relation , Closure $callback ) : Builder |static
Add a relationship count / exists condition to the query with where clauses.
Parameters
- $relation string
- $callback Closure |null
orWhereDoesntHave ( $relation , Closure $callback ) : Builder |static
Add a relationship count / exists condition to the query with where clauses and an "or".
Parameters
- $relation string
- $callback Closure |null
hasMorph ( $relation , $types , $operator , $count , $boolean , Closure $callback ) : Builder |static
Add a polymorphic relationship count / exists condition to the query.
Parameters
getBelongsToRelation ( MorphTo $relation , $type ) : BelongsTo
Get the BelongsTo relationship for a single polymorphic type.
Parameters
- $relation MorphTo
- $type string
orHasMorph ( $relation , $types , $operator , $count ) : Builder |static
Add a polymorphic relationship count / exists condition to the query with an "or".
Parameters
- $relation MorphTo |string
- $types string|array
- $operator string
- $count int
doesntHaveMorph ( $relation , $types , $boolean , Closure $callback ) : Builder |static
Add a polymorphic relationship count / exists condition to the query.
Parameters
orDoesntHaveMorph ( $relation , $types ) : Builder |static
Add a polymorphic relationship count / exists condition to the query with an "or".
Parameters
- $relation MorphTo |string
- $types string|array
whereHasMorph ( $relation , $types , Closure $callback , $operator , $count ) : Builder |static
Add a polymorphic relationship count / exists condition to the query with where clauses.
Parameters
orWhereHasMorph ( $relation , $types , Closure $callback , $operator , $count ) : Builder |static
Add a polymorphic relationship count / exists condition to the query with where clauses and an "or".
Parameters
whereDoesntHaveMorph ( $relation , $types , Closure $callback ) : Builder |static
Add a polymorphic relationship count / exists condition to the query with where clauses.
Parameters
orWhereDoesntHaveMorph ( $relation , $types , Closure $callback ) : Builder |static
Add a polymorphic relationship count / exists condition to the query with where clauses and an "or".
Parameters
whereRelation ( $relation , $column , $operator , $value ) : Builder |static
Add a basic where clause to a relationship query.
Parameters
- $relation string
- $column Closure |string|array|Expression
- $operator mixed
- $value mixed
orWhereRelation ( $relation , $column , $operator , $value ) : Builder |static
Add an "or where" clause to a relationship query.
Parameters
- $relation string
- $column Closure |string|array|Expression
- $operator mixed
- $value mixed
whereMorphRelation ( $relation , $types , $column , $operator , $value ) : Builder |static
Add a polymorphic relationship condition to the query with a where clause.
Parameters
- $relation MorphTo |string
- $types string|array
- $column Closure |string|array|Expression
- $operator mixed
- $value mixed
orWhereMorphRelation ( $relation , $types , $column , $operator , $value ) : Builder |static
Add a polymorphic relationship condition to the query with an "or where" clause.
Parameters
- $relation MorphTo |string
- $types string|array
- $column Closure |string|array|Expression
- $operator mixed
- $value mixed
whereMorphedTo ( $relation , $model , $boolean ) : Builder |static
Add a morph-to relationship condition to the query.
Parameters
orWhereMorphedTo ( $relation , $model ) : Builder |static
Add a morph-to relationship condition to the query with an "or where" clause.
Parameters
whereBelongsTo ( $related , $relationshipName , $boolean ) : $this
Add a "belongs to" relationship where clause to the query.
Parameters
- $related Model
- $relationship string
- $boolean string
orWhereBelongsTo ( $related , $relationshipName ) : $this
Add an "BelongsTo" relationship with an "or where" clause to the query.
Parameters
- $related Model
- $relationship string
withAggregate ( $relations , $column , $function ) : $this
Add subselect queries to include an aggregate value for a relationship.
Parameters
- $relations mixed
- $column string
- $function string
withCount ( $relations ) : $this
Add subselect queries to count the relations.
Parameters
- $relations mixed
withMax ( $relation , $column ) : $this
Add subselect queries to include the max of the relation's column.
Parameters
- $relation string|array
- $column string
withMin ( $relation , $column ) : $this
Add subselect queries to include the min of the relation's column.
Parameters
- $relation string|array
- $column string
withSum ( $relation , $column ) : $this
Add subselect queries to include the sum of the relation's column.
Parameters
- $relation string|array
- $column string
withAvg ( $relation , $column ) : $this
Add subselect queries to include the average of the relation's column.
Parameters
- $relation string|array
- $column string
withExists ( $relation ) : $this
Add subselect queries to include the existence of related models.
Parameters
- $relation string|array
addHasWhere ( Builder $hasQuery , Relation $relation , $operator , $count , $boolean ) : Builder |static
Add the "has" condition where clause to the query.
Parameters
mergeConstraintsFrom ( Builder $from ) : Builder |static
Merge the where constraints from another query to the current query.
Parameters
- $from Builder
addWhereCountQuery ( Builder $query , $operator , $count , $boolean ) : $this
Add a sub-query count clause to this query.
Parameters
- $query Builder
- $operator string
- $count int
- $boolean string
getRelationWithoutConstraints ( $relation ) : Relation
Get the "has relation" base query instance.
Parameters
- $relation string
canUseExistsForExistenceCheck ( $operator , $count ) : bool
Check if we can run an "exists" query to optimize performance.
Parameters
- $operator string
- $count int