Methods |
public
static
|
resolveRelationUsing(string $name, Closure $callback): void
Define a dynamic relation resolver.
Define a dynamic relation resolver.
|
#
|
public
|
hasOne(string $related, string|null $foreignKey = null, string|null $localKey = null): HasOne
Define a one-to-one relationship.
Define a one-to-one relationship.
|
#
|
public
|
hasOneThrough(
string $related,
string $through,
string|null $firstKey = null,
string|null $secondKey = null,
string|null $localKey = null,
string|null $secondLocalKey = null,
): HasOneThrough
Define a has-one-through relationship.
Define a has-one-through relationship.
|
#
|
public
|
morphOne(
string $related,
string $name,
string|null $type = null,
string|null $id = null,
string|null $localKey = null,
): MorphOne
Define a polymorphic one-to-one relationship.
Define a polymorphic one-to-one relationship.
|
#
|
public
|
belongsTo(
string $related,
string|null $foreignKey = null,
string|null $ownerKey = null,
string|null $relation = null,
): BelongsTo
Define an inverse one-to-one or many relationship.
Define an inverse one-to-one or many relationship.
|
#
|
public
|
morphTo(
string|null $name = null,
string|null $type = null,
string|null $id = null,
string|null $ownerKey = null,
): MorphTo
Define a polymorphic, inverse one-to-one or many relationship.
Define a polymorphic, inverse one-to-one or many relationship.
|
#
|
public
static
|
getActualClassNameForMorph(string $class): string
Retrieve the actual class name for a given morph class.
Retrieve the actual class name for a given morph class.
|
#
|
public
|
hasMany(string $related, string|null $foreignKey = null, string|null $localKey = null): HasMany
Define a one-to-many relationship.
Define a one-to-many relationship.
|
#
|
public
|
hasManyThrough(
string $related,
string $through,
string|null $firstKey = null,
string|null $secondKey = null,
string|null $localKey = null,
string|null $secondLocalKey = null,
): HasManyThrough
Define a has-many-through relationship.
Define a has-many-through relationship.
|
#
|
public
|
morphMany(
string $related,
string $name,
string|null $type = null,
string|null $id = null,
string|null $localKey = null,
): MorphMany
Define a polymorphic one-to-many relationship.
Define a polymorphic one-to-many relationship.
|
#
|
public
|
belongsToMany(
string $related,
string|null $table = null,
string|null $foreignPivotKey = null,
string|null $relatedPivotKey = null,
string|null $parentKey = null,
string|null $relatedKey = null,
string|null $relation = null,
): BelongsToMany
Define a many-to-many relationship.
Define a many-to-many relationship.
|
#
|
public
|
morphToMany(
string $related,
string $name,
string|null $table = null,
string|null $foreignPivotKey = null,
string|null $relatedPivotKey = null,
string|null $parentKey = null,
string|null $relatedKey = null,
bool $inverse = false,
): MorphToMany
Define a polymorphic many-to-many relationship.
Define a polymorphic many-to-many relationship.
|
#
|
public
|
morphedByMany(
string $related,
string $name,
string|null $table = null,
string|null $foreignPivotKey = null,
string|null $relatedPivotKey = null,
string|null $parentKey = null,
string|null $relatedKey = null,
): MorphToMany
Define a polymorphic, inverse many-to-many relationship.
Define a polymorphic, inverse many-to-many relationship.
|
#
|
public
|
joiningTable(string $related, Model|null $instance = null): string
Get the joining table name for a many-to-many relation.
Get the joining table name for a many-to-many relation.
|
#
|
public
|
joiningTableSegment(): string
Get this model's half of the intermediate table name for belongsToMany relationships.
Get this model's half of the intermediate table name for belongsToMany relationships.
|
#
|
public
|
touches(string $relation): bool
Determine if the model touches a given relation.
Determine if the model touches a given relation.
|
#
|
public
|
touchOwners(): void
Touch the owning relations of the model.
Touch the owning relations of the model.
|
#
|
public
|
getMorphClass(): string
Get the class name for polymorphic relations.
Get the class name for polymorphic relations.
|
#
|
public
|
getRelations(): array
Get all the loaded relations for the instance.
Get all the loaded relations for the instance.
|
#
|
public
|
getRelation(string $relation): mixed
Get a specified relationship.
Get a specified relationship.
|
#
|
public
|
relationLoaded(string $key): bool
Determine if the given relation is loaded.
Determine if the given relation is loaded.
|
#
|
public
|
setRelation(string $relation, mixed $value): $this
Set the given relationship on the model.
Set the given relationship on the model.
|
#
|
public
|
unsetRelation(string $relation): $this
Unset a loaded relationship.
Unset a loaded relationship.
|
#
|
public
|
setRelations(array $relations): $this
Set the entire relations array on the model.
Set the entire relations array on the model.
|
#
|
public
|
withoutRelations(): $this
Duplicate the instance and unset all the loaded relations.
Duplicate the instance and unset all the loaded relations.
|
#
|
public
|
unsetRelations(): $this
Unset all the loaded relations for the instance.
Unset all the loaded relations for the instance.
|
#
|
public
|
getTouchedRelations(): array
Get the relationships that are touched on save.
Get the relationships that are touched on save.
|
#
|
public
|
setTouchedRelations(array $touches): $this
Set the relationships that are touched on save.
Set the relationships that are touched on save.
|
#
|