CanBeOneOfMany
trait CanBeOneOfMany
Properties
| protected bool | $isOneOfMany | Determines whether the relationship is one-of-many. |
|
| protected string | $relationName | The name of the relationship. |
|
| protected Builder<mixed>|null | $oneOfManySubQuery | The one of many inner join subselect query builder instance. |
|
| protected Model|null | $oneOfManyJoinModel | The model of the query the one of many subselect is currently being joined to. |
Methods
Add constraints for inner join subselect for one of many relationships.
Get the columns the determine the relationship groups.
Add join query constraints for one of many relationships.
Indicate that the relation is the latest single result of a larger one-to-many relationship.
Indicate that the relation is the oldest single result of a larger one-to-many relationship.
Get the default alias for the one of many inner join clause.
Get a new query for the related model, grouping the query by the given column, often the foreign key of the relationship.
Add the join subquery to the given query on the given column and the relationship's foreign key.
Merge the relationship query joins to the given query builder.
Get the query builder that will contain the relationship constraints.
Get the one of many inner join subselect builder instance.
Get the qualified column name for the one-of-many relationship using the subselect join query's alias.
Qualify related column using the related table name if it is not already qualified.
Guess the "hasOne" relationship's name via backtrace.
Determine whether the relationship is a one-of-many relationship.
Get the name of the relationship.
Details
at line 44
abstract void
addOneOfManySubQueryConstraints(Builder $query, string|null $column = null, string|null $aggregate = null)
Add constraints for inner join subselect for one of many relationships.
at line 49
abstract array|string
getOneOfManySubQuerySelectColumns()
Get the columns the determine the relationship groups.
at line 54
abstract void
addOneOfManyJoinSubQueryConstraints(JoinClause $join)
Add join query constraints for one of many relationships.
at line 63
CanBeOneOfMany
ofMany(string|array|null $column = 'id', string|Closure|null $aggregate = 'MAX', string|null $relation = null)
Indicate that the relation is a single result of a larger one-to-many relationship.
at line 143
CanBeOneOfMany
latestOfMany(string|array|null $column = 'id', string|null $relation = null)
Indicate that the relation is the latest single result of a larger one-to-many relationship.
at line 155
CanBeOneOfMany
oldestOfMany(string|array|null $column = 'id', string|null $relation = null)
Indicate that the relation is the oldest single result of a larger one-to-many relationship.
at line 165
protected string
getDefaultOneOfManyJoinAlias(string $relation)
Get the default alias for the one of many inner join clause.
at line 182
protected Builder
newOneOfManySubQuery(string|array $groupBy, array|null $columns = null, string|null $aggregate = null)
Get a new query for the related model, grouping the query by the given column, often the foreign key of the relationship.
at line 218
protected void
addOneOfManyJoinSubQuery(Builder $parent, Builder $subQuery, array $on)
Add the join subquery to the given query on the given column and the relationship's foreign key.
at line 242
protected void
mergeOneOfManyJoinsTo(Builder $query)
Merge the relationship query joins to the given query builder.
at line 254
protected Builder
getRelationQuery()
Get the query builder that will contain the relationship constraints.
at line 266
Builder|null
getOneOfManySubQuery()
Get the one of many inner join subselect builder instance.
at line 274
string
qualifySubSelectColumn(string $column)
Get the qualified column name for the one-of-many relationship using the subselect join query's alias.
at line 282
protected string
qualifyRelatedColumn(string $column)
Qualify related column using the related table name if it is not already qualified.
at line 290
protected string
guessRelationship()
Guess the "hasOne" relationship's name via backtrace.
at line 300
bool
isOneOfMany()
Determine whether the relationship is a one-of-many relationship.
at line 308
string
getRelationName()
Get the name of the relationship.