Spec-Zone.ru › Laravel 5.6

HasRelationships

trait HasRelationships (View source)

Свойства

protected массив $relations Загруженные отношения для модели.
protected массив $touches Отношения, которые должны быть затронуты при сохранении.
static массив $manyMethods Методы отношений многие ко многим.

Методы

HasOne hasOne(string $related, string $foreignKey = null, string $localKey = null)

Определить отношение один-к-одному.

HasOne newHasOne(Builder $query, Model $parent, string $foreignKey, string $localKey)

Создать новое отношение HasOne.

MorphOne morphOne(string $related, string $name, string $type = null, string $id = null, string $localKey = null)

Определить полиморфное отношение один-к-одному.

MorphOne newMorphOne(Builder $query, Model $parent, string $type, string $id, string $localKey)

Создать новое отношение MorphOne.

BelongsTo belongsTo(string $related, string $foreignKey = null, string $ownerKey = null, string $relation = null)

Определить обратное отношение один-к-одному или многие-к-одному.

BelongsTo newBelongsTo(Builder $query, Model $child, string $foreignKey, string $ownerKey, string $relation)

Создать новое отношение BelongsTo.

MorphTo morphTo(string $name = null, string $type = null, string $id = null, string $ownerKey = null)

Определить полиморфное, обратное отношение один-к-одному или многие-к-одному.

MorphTo morphEagerTo(string $name, string $type, string $id, string $ownerKey)

Определить полиморфное, обратное отношение один-к-одному или многие-к-одному.

MorphTo morphInstanceTo(string $target, string $name, string $type, string $id, string $ownerKey)

Определить полиморфное, обратное отношение один-к-одному или многие-к-одному.

MorphTo newMorphTo(Builder $query, Model $parent, string $foreignKey, string $ownerKey, string $type, string $relation)

Создать новое отношение MorphTo.

static string getActualClassNameForMorph(string $class)

Получить фактическое имя класса для заданного морф-класса.

string guessBelongsToRelation()

Угадать имя отношения "принадлежит к".

HasMany hasMany(string $related, string $foreignKey = null, string $localKey = null)

Определить отношение один-ко-многим.

HasMany newHasMany(Builder $query, Model $parent, string $foreignKey, string $localKey)

Создать новое отношение HasMany.

HasManyThrough hasManyThrough(string $related, string $through, string|null $firstKey = null, string|null $secondKey = null, string|null $localKey = null, string|null $secondLocalKey = null)

Определить отношение многие-через-многие.

HasManyThrough newHasManyThrough(Builder $query, Model $farParent, Model $throughParent, string $firstKey, string $secondKey, string $localKey, string $secondLocalKey)

Создать новое отношение HasManyThrough.

MorphMany morphMany(string $related, string $name, string $type = null, string $id = null, string $localKey = null)

Определить полиморфное отношение один-ко-многим.

MorphMany newMorphMany(Builder $query, Model $parent, string $type, string $id, string $localKey)

Создать новое отношение MorphMany.

BelongsToMany belongsToMany(string $related, string $table = null, string $foreignPivotKey = null, string $relatedPivotKey = null, string $parentKey = null, string $relatedKey = null, string $relation = null)

Определить отношение многие-ко-многим.

BelongsToMany newBelongsToMany(Builder $query, Model $parent, string $table, string $foreignPivotKey, string $relatedPivotKey, string $parentKey, string $relatedKey, string $relationName = null)

Создать новое отношение BelongsToMany.

MorphToMany morphToMany(string $related, string $name, string $table = null, string $foreignPivotKey = null, string $relatedPivotKey = null, string $parentKey = null, string $relatedKey = null, bool $inverse = false)

Определить полиморфное отношение многие-ко-многим.

MorphToMany newMorphToMany(Builder $query, Model $parent, string $name, string $table, string $foreignPivotKey, string $relatedPivotKey, string $parentKey, string $relatedKey, string $relationName = null, bool $inverse = false)

Создать новое отношение MorphToMany.

MorphToMany morphedByMany(string $related, string $name, string $table = null, string $foreignPivotKey = null, string $relatedPivotKey = null, string $parentKey = null, string $relatedKey = null)

Определить полиморфное, обратное отношение многие-ко-многим.

string guessBelongsToManyRelation()

Получить имя отношения belongs to many.

string joiningTable(string $related)

Получить имя таблицы соединения для отношения многие-ко-многим.

bool touches(string $relation)

Определить, затрагивает ли модель данное отношение.

void touchOwners()

Затронуть отношения владения модели.

массив getMorphs(string $name, string $type, string $id)

Получить столбцы полиморфного отношения.

строка getMorphClass()

Получить имя класса для полиморфных отношений.

смешанный newRelatedInstance(string $class)

Создать новый экземпляр модели для связанной модели.

массив getRelations()

Получить все загруженные отношения для экземпляра.

смешанный getRelation(string $relation)

Получить указанное отношение.

логическое значение relationLoaded(string $key)

Определить, загружено ли данное отношение.

$this setRelation(string $relation, mixed $value)

Установить данное отношение в модели.

$this unsetRelation(string $relation)

Удалить загруженное отношение.

$this setRelations(array $relations)

Установить весь массив отношений в модели.

массив getTouchedRelations()

Получить отношения, которые затрагиваются при сохранении.

$this setTouchedRelations(array $touches)

Установить отношения, которые затрагиваются при сохранении.

Подробности

HasOne hasOne(string $related, string $foreignKey = null, string $localKey = null)

Определить отношение один-к-одному.

Параметры

строка $related
строка $foreignKey
строка $localKey

Возвращаемое значение

HasOne

protected HasOne newHasOne(Builder $query, Model $parent, string $foreignKey, string $localKey)

Создать новое отношение один-к-одному.

Параметры

Builder $query
Model $parent
строка $foreignKey
строка $localKey

Возвращаемое значение

HasOne

MorphOne morphOne(string $related, string $name, string $type = null, string $id = null, string $localKey = null)

Определить полиморфное отношение один-к-одному.

Параметры

строка $related
строка $name
строка $type
строка $id
строка $localKey

Возвращаемое значение

MorphOne

protected MorphOne newMorphOne(Builder $query, Model $parent, string $type, string $id, string $localKey)

Создать новое полиморфное отношение один-к-одному.

Параметры

Builder $query
Model $parent
строка $type
строка $id
строка $localKey

Возвращаемое значение

MorphOne

BelongsTo belongsTo(string $related, string $foreignKey = null, string $ownerKey = null, string $relation = null)

Определить обратное отношение один-к-одному или один-ко-многим.

Параметры

строка $related
строка $foreignKey
строка $ownerKey
строка $relation

Возвращаемое значение

BelongsTo

protected BelongsTo newBelongsTo(Builder $query, Model $child, string $foreignKey, string $ownerKey, string $relation)

Создать новое отношение BelongsTo.

Параметры

Builder $query
Model $child
строка $foreignKey
строка $ownerKey
строка $relation

Возвращаемое значение

BelongsTo

MorphTo morphTo(string $name = null, string $type = null, string $id = null, string $ownerKey = null)

Определить полиморфное обратное отношение один-к-одному или один-ко-многим.

Параметры

строка $name
строка $type
строка $id
строка $ownerKey

Возвращаемое значение

MorphTo

protected MorphTo morphEagerTo(string $name, string $type, string $id, string $ownerKey)

Определить полиморфное обратное отношение один-к-одному или один-ко-многим.

Параметры

строка $name
строка $type
строка $id
строка $ownerKey

Возвращаемое значение

MorphTo

protected MorphTo morphInstanceTo(string $target, string $name, string $type, string $id, string $ownerKey)

Определить полиморфное обратное отношение один-к-одному или один-ко-многим.

Параметры

строка $target
строка $name
строка $type
строка $id
строка $ownerKey

Возвращаемое значение

MorphTo

protected MorphTo newMorphTo(Builder $query, Model $parent, string $foreignKey, string $ownerKey, string $type, string $relation)

Создать новое отношение MorphTo.

Параметры

Builder $query
Model $parent
string $foreignKey
string $ownerKey
string $type
string $relation

Возвращаемое значение

MorphTo

static string getActualClassNameForMorph(string $class)

Получить фактическое имя класса для заданного класса morph.

Параметры

string $class

Возвращаемое значение

string

protected string guessBelongsToRelation()

Угадать имя отношения «belongs to».

Возвращаемое значение

string

HasMany hasMany(string $related, string $foreignKey = null, string $localKey = null)

Определить отношение один ко многим.

Параметры

string $related
string $foreignKey
string $localKey

Возвращаемое значение

HasMany

protected HasMany newHasMany(Builder $query, Model $parent, string $foreignKey, string $localKey)

Создать новое отношение HasMany.

Параметры

Builder $query
Model $parent
string $foreignKey
string $localKey

Возвращаемое значение

HasMany

HasManyThrough hasManyThrough(string $related, string $through, string|null $firstKey = null, string|null $secondKey = null, string|null $localKey = null, string|null $secondLocalKey = null)

Определить отношение has-many-through.

Параметры

string $related
string $through
string|null $firstKey
string|null $secondKey
string|null $localKey
string|null $secondLocalKey

Возвращаемое значение

HasManyThrough

protected HasManyThrough newHasManyThrough(Builder $query, Model $farParent, Model $throughParent, string $firstKey, string $secondKey, string $localKey, string $secondLocalKey)

Создать новое отношение HasManyThrough.

Параметры

Builder $query
Model $farParent
Model $throughParent
string $firstKey
string $secondKey
string $localKey
string $secondLocalKey

Возвращаемое значение

HasManyThrough

MorphMany morphMany(string $related, string $name, string $type = null, string $id = null, string $localKey = null)

Определить полиморфное отношение один ко многим.

Параметры

string $related
string $name
string $type
string $id
string $localKey

Возвращаемое значение

MorphMany

protected MorphMany newMorphMany(Builder $query, Model $parent, string $type, string $id, string $localKey)

Создать новое отношение MorphMany.

Параметры

Builder $query
Model $parent
string $type
string $id
string $localKey

Возвращаемое значение

MorphMany

BelongsToMany belongsToMany(string $related, string $table = null, string $foreignPivotKey = null, string $relatedPivotKey = null, string $parentKey = null, string $relatedKey = null, string $relation = null)

Определить отношение многие ко многим.

Параметры

string $related
string $table
string $foreignPivotKey
string $relatedPivotKey
string $parentKey
string $relatedKey
string $relation

Возвращаемое значение

BelongsToMany

protected BelongsToMany newBelongsToMany(Builder $query, Model $parent, string $table, string $foreignPivotKey, string $relatedPivotKey, string $parentKey, string $relatedKey, string $relationName = null)

Создать новую связь BelongsToMany.

Параметры

Builder $query
Model $parent
string $table
string $foreignPivotKey
string $relatedPivotKey
string $parentKey
string $relatedKey
string $relationName

Возвращаемое значение

BelongsToMany

MorphToMany morphToMany(string $related, string $name, string $table = null, string $foreignPivotKey = null, string $relatedPivotKey = null, string $parentKey = null, string $relatedKey = null, bool $inverse = false)

Определить полиморфную связь many-to-many.

Параметры

string $related
string $name
string $table
string $foreignPivotKey
string $relatedPivotKey
string $parentKey
string $relatedKey
bool $inverse

Возвращаемое значение

MorphToMany

protected MorphToMany newMorphToMany(Builder $query, Model $parent, string $name, string $table, string $foreignPivotKey, string $relatedPivotKey, string $parentKey, string $relatedKey, string $relationName = null, bool $inverse = false)

Создать новую полиморфную связь many-to-many.

Параметры

Builder $query
Model $parent
string $name
string $table
string $foreignPivotKey
string $relatedPivotKey
string $parentKey
string $relatedKey
string $relationName
bool $inverse

Возвращаемое значение

MorphToMany

MorphToMany morphedByMany(string $related, string $name, string $table = null, string $foreignPivotKey = null, string $relatedPivotKey = null, string $parentKey = null, string $relatedKey = null)

Определить полиморфную обратную связь many-to-many.

Параметры

string $related
string $name
string $table
string $foreignPivotKey
string $relatedPivotKey
string $parentKey
string $relatedKey

Возвращаемое значение

MorphToMany

protected string guessBelongsToManyRelation()

Получить имя связи belongs to many.

Возвращаемое значение

string

string joiningTable(string $related)

Получить имя таблицы соединения для связи many-to-many.

Параметры

string $related

Возвращаемое значение

string

bool touches(string $relation)

Определить, касается ли модель заданную связь.

Параметры

string $relation

Возвращаемое значение

bool

void touchOwners()

Обновить связанные отношения модели.

Возвращаемое значение

void

protected array getMorphs(string $name, string $type, string $id)

Получить столбцы полиморфной связи.

Параметры

string $name
string $type
string $id

Возвращаемое значение

array

string getMorphClass()

Получить имя класса для полиморфных связей.

Возвращаемое значение

string

protected mixed newRelatedInstance(string $class)

Создать новый экземпляр модели для связанной модели.

Параметры

string $class

Возвращаемое значение

mixed

array getRelations()

Получить все загруженные отношения для экземпляра.

Возвращаемое значение

array

mixed getRelation(string $relation)

Получить указанное отношение.

Параметры

string $relation

Возвращаемое значение

mixed

bool relationLoaded(string $key)

Определить, загружено ли данное отношение.

Параметры

string $key

Возвращаемое значение

bool

$this setRelation(string $relation, mixed $value)

Установить заданное отношение для модели.

Параметры

string $relation
mixed $value

Возвращаемое значение

$this

$this unsetRelation(string $relation)

Удалить загруженное отношение.

Параметры

string $relation

Возвращаемое значение

$this

$this setRelations(array $relations)

Установить массив отношений для модели.

Параметры

массив $relations

Возвращаемое значение

$this

array getTouchedRelations()

Получить отношения, которые затрагиваются при сохранении.

Возвращаемое значение

массив

$this setTouchedRelations(array $touches)

Установить отношения, которые затрагиваются при сохранении.

Параметры

массив $touches

Возвращаемое значение

$this

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.6/Illuminate/Database/Eloquent/Concerns/HasRelationships.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API