Relation
abstract class Relation mixin Builder
Traits
Properties
static protected array | $macros | The registered string macros. |
from Macroable |
protected Builder | $query | The Eloquent query builder instance. |
|
protected Model | $parent | The parent model instance. |
|
protected Model | $related | The related model instance. |
|
static protected bool | $constraints | Indicates if the relation is adding constraints. |
|
static protected array | $morphMap | An array to map class names to their morph names in database. |
Methods
Dynamically handle calls to the class.
Handle dynamic method calls to the relationship.
Set the base constraints on the relation query.
Set the constraints for an eager load of the relation.
Initialize the relation on a set of models.
Match the eagerly loaded results to their parents.
Get the results of the relationship.
Get the relationship for eager loading.
Touch all of the related models for the relationship.
Run a raw update against the base query.
Add the constraints for a relationship count query.
Add the constraints for an internal relationship existence query.
Get all of the primary keys for an array of models.
Get the base query builder driving the Eloquent builder.
Get the fully qualified parent key name.
Get the related model of the relation.
Get the name of the "created at" column.
Get the name of the "updated at" column.
Get the name of the related model's "updated at" column.
Set or get the morph map for polymorphic relations.
Builds a table-keyed array from model class names.
Get the model associated with a custom polymorphic type.
Force a clone of the underlying query builder when cloning.
Details
in
Macroable at line 24
static void
macro(string $name, callable $macro)
Register a custom macro.
in
Macroable at line 35
static bool
hasMacro(string $name)
Checks if macro is registered.
in
Macroable at line 49
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
at line 350
mixed
__call(string $method, array $parameters)
Handle dynamic method calls to the relationship.
at line 79
static mixed
noConstraints(Closure $callback)
Run a callback with constraints disabled on the relation.
at line 100
abstract void
addConstraints()
Set the base constraints on the relation query.
at line 108
abstract void
addEagerConstraints(array $models)
Set the constraints for an eager load of the relation.
at line 117
abstract array
initRelation(array $models, string $relation)
Initialize the relation on a set of models.
at line 127
abstract array
match(array $models, Collection $results, string $relation)
Match the eagerly loaded results to their parents.
at line 134
abstract mixed
getResults()
Get the results of the relationship.
at line 141
Collection
getEager()
Get the relationship for eager loading.
at line 151
void
touch()
Touch all of the related models for the relationship.
at line 164
int
rawUpdate(array $attributes = [])
Run a raw update against the base query.
at line 176
Builder
getRelationExistenceCountQuery(Builder $query, Builder $parentQuery)
Add the constraints for a relationship count query.
at line 193
Builder
getRelationExistenceQuery(Builder $query, Builder $parentQuery, array|mixed $columns = ['*'])
Add the constraints for an internal relationship existence query.
Essentially, these queries compare on column names like whereColumn.
at line 207
protected array
getKeys(array $models, string $key = null)
Get all of the primary keys for an array of models.
at line 219
Builder
getQuery()
Get the underlying query for the relation.
at line 229
Builder
getBaseQuery()
Get the base query builder driving the Eloquent builder.
at line 239
Model
getParent()
Get the parent model of the relation.
at line 249
string
getQualifiedParentKeyName()
Get the fully qualified parent key name.
at line 259
Model
getRelated()
Get the related model of the relation.
at line 269
string
createdAt()
Get the name of the "created at" column.
at line 279
string
updatedAt()
Get the name of the "updated at" column.
at line 289
string
relatedUpdatedAt()
Get the name of the related model's "updated at" column.
at line 301
static array
morphMap(array $map = null, bool $merge = true)
Set or get the morph map for polymorphic relations.
at line 319
static protected array|null
buildMorphMapFromModels(array $models = null)
Builds a table-keyed array from model class names.
at line 336
static string|null
getMorphedModel(string $alias)
Get the model associated with a custom polymorphic type.
at line 370
void
__clone()
Force a clone of the underlying query builder when cloning.