Spec-Zone.ru › Laravel 8

Связи запросов

свойство Связи запросов (Просмотреть исходный код)

Методы

Builder|QueriesRelationships has(Relation|string $relation, string $operator = '>=', int $count = 1, string $boolean = 'and', Closure $callback = null)

Добавить условие подсчёта/существования связи к запросу.

Builder|QueriesRelationships hasNested(string $relations, string $operator = '>=', int $count = 1, string $boolean = 'and', Closure|null $callback = null)

Добавить условия подсчёта/существования вложенных связей к запросу.

Builder|QueriesRelationships orHas(string $relation, string $operator = '>=', int $count = 1)

Добавить условие подсчёта/существования связи к запросу с "или".

Builder|QueriesRelationships doesntHave(string $relation, string $boolean = 'and', Closure $callback = null)

Добавить условие подсчёта/отсутствия связи к запросу.

Builder|QueriesRelationships orDoesntHave(string $relation)

Добавить условие подсчёта/отсутствия связи к запросу с "или".

Builder|QueriesRelationships whereHas(string $relation, Closure $callback = null, string $operator = '>=', int $count = 1)

Добавить условие подсчёта/существования связи к запросу со словами where.

Builder|QueriesRelationships orWhereHas(string $relation, Closure $callback = null, string $operator = '>=', int $count = 1)

Добавить условие подсчёта/существования связи к запросу со словами where и "или".

Builder|QueriesRelationships whereDoesntHave(string $relation, Closure $callback = null)

Добавить условие подсчёта/отсутствия связи к запросу со словами where.

Builder|QueriesRelationships orWhereDoesntHave(string $relation, Closure $callback = null)

Добавить условие подсчёта/отсутствия связи к запросу со словами where и "или".

Builder|QueriesRelationships hasMorph(MorphTo|string $relation, string|array $types, string $operator = '>=', int $count = 1, string $boolean = 'and', Closure $callback = null)

Добавить условие подсчёта/существования полиморфной связи к запросу.

BelongsTo getBelongsToRelation(MorphTo $relation, string $type)

Получить связь BelongsTo для одного полиморфного типа.

Builder|QueriesRelationships orHasMorph(MorphTo|string $relation, string|array $types, string $operator = '>=', int $count = 1)

Добавить условие подсчёта/существования полиморфной связи к запросу с "или".

Builder|QueriesRelationships doesntHaveMorph(MorphTo|string $relation, string|array $types, string $boolean = 'and', Closure $callback = null)

Добавить условие подсчёта/отсутствия полиморфной связи к запросу.

Builder|QueriesRelationships orDoesntHaveMorph(MorphTo|string $relation, string|array $types)

Добавить условие подсчёта/отсутствия полиморфной связи к запросу с "или".

Builder|QueriesRelationships whereHasMorph(MorphTo|string $relation, string|array $types, Closure $callback = null, string $operator = '>=', int $count = 1)

Добавить условие подсчёта/существования полиморфной связи к запросу со словами where.

Builder|QueriesRelationships orWhereHasMorph(MorphTo|string $relation, string|array $types, Closure $callback = null, string $operator = '>=', int $count = 1)

Добавить условие подсчёта/существования полиморфной связи к запросу со словами where и "или".

Builder|QueriesRelationships whereDoesntHaveMorph(MorphTo|string $relation, string|array $types, Closure $callback = null)

Добавить условие подсчёта/отсутствия полиморфной связи к запросу со словами where.

Builder|QueriesRelationships orWhereDoesntHaveMorph(MorphTo|string $relation, string|array $types, Closure $callback = null)

Добавить условие подсчёта/отсутствия полиморфной связи к запросу со словами where и "или".

Builder|QueriesRelationships whereRelation(string $relation, Closure|string|array|Expression $column, mixed $operator = null, mixed $value = null)

Добавить базовое условие where к запросу по связи.

Builder|QueriesRelationships orWhereRelation(string $relation, Closure|string|array|Expression $column, mixed $operator = null, mixed $value = null)

Добавить условие «или где» к запросу к связи.

Builder|QueriesRelationships whereMorphRelation(MorphTo|string $relation, string|array $types, Closure|string|array|Expression $column, mixed $operator = null, mixed $value = null)

Добавить условие полиморфной связи к запросу с помощью условия «где».

Builder|QueriesRelationships orWhereMorphRelation(MorphTo|string $relation, string|array $types, Closure|string|array|Expression $column, mixed $operator = null, mixed $value = null)

Добавить условие полиморфной связи к запросу с помощью условия «или где».

Builder|QueriesRelationships whereMorphedTo(MorphTo|string $relation, Model|string $model, $boolean = 'and')

Добавить условие связи «morph-to» к запросу.

Builder|QueriesRelationships orWhereMorphedTo(MorphTo|string $relation, Model|string $model)

Добавить условие связи «morph-to» к запросу с помощью условия «или где».

$this whereBelongsTo(Model $related, $relationshipName = null, string $boolean = 'and')

Добавить условие связи «belongs to» к запросу.

$this orWhereBelongsTo(Model $related, $relationshipName = null)

Добавить условие связи «BelongsTo» с условием «или где» к запросу.

$this withAggregate(mixed $relations, string $column, string $function = null)

Добавить подзапросы для включения агрегированного значения для связи.

$this withCount(mixed $relations)

Добавить подзапросы для подсчета связей.

$this withMax(string|array $relation, string $column)

Добавить подзапросы для включения максимального значения столбца связи.

$this withMin(string|array $relation, string $column)

Добавить подзапросы для включения минимального значения столбца связи.

$this withSum(string|array $relation, string $column)

Добавить подзапросы для включения суммы столбца связи.

$this withAvg(string|array $relation, string $column)

Добавить подзапросы для включения среднего значения столбца связи.

$this withExists(string|array $relation)

Добавить подзапросы для включения проверки существования связанных моделей.

Builder|QueriesRelationships addHasWhere(Builder $hasQuery, Relation $relation, string $operator, int $count, string $boolean)

Добавить условие «has» в запрос.

Builder|QueriesRelationships mergeConstraintsFrom(Builder $from)

Объединить условия «где» из другого запроса в текущий запрос.

$this addWhereCountQuery(Builder $query, string $operator = '>=', int $count = 1, string $boolean = 'and')

Добавить условие подзапроса «счет» к текущему запросу.

Relation getRelationWithoutConstraints(string $relation)

Получить базовый экземпляр запроса «has relation».

bool canUseExistsForExistenceCheck(string $operator, int $count)

Проверить, можем ли мы выполнить запрос «exists» для оптимизации производительности.

Подробности

Builder|QueriesRelationships has(Relation|string $relation, string $operator = '>=', int $count = 1, string $boolean = 'and', Closure $callback = null)

Добавить условие подсчёта/существования отношения к запросу.

Параметры

Relation|string $relation
string $operator
int $count
string $boolean
Closure $callback

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

Builder|QueriesRelationships

Исключения

RuntimeException

protected Builder|QueriesRelationships hasNested(string $relations, string $operator = '>=', int $count = 1, string $boolean = 'and', Closure|null $callback = null)

Добавить условия подсчёта/существования вложенных отношений к запросу.

Настраивает рекурсивный вызов whereHas до завершения вложенного отношения.

Параметры

string $relations
string $operator
int $count
string $boolean
Closure|null $callback

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

Builder|QueriesRelationships

Builder|QueriesRelationships orHas(string $relation, string $operator = '>=', int $count = 1)

Добавить условие подсчёта/существования связи к запросу с оператором "или".

Parameters

string $relation
string $operator
int $count

Return Value

Builder|QueriesRelationships

Builder|QueriesRelationships doesntHave(string $relation, string $boolean = 'and', Closure $callback = null)

Добавить условие подсчёта/существования связи к запросу.

Parameters

string $relation
string $boolean
Closure $callback

Return Value

Builder|QueriesRelationships

Builder|QueriesRelationships orDoesntHave(string $relation)

Добавить условие подсчёта/существования связи к запросу с оператором "или".

Parameters

string $relation

Return Value

Builder|QueriesRelationships

Builder|QueriesRelationships whereHas(string $relation, Closure $callback = null, string $operator = '>=', int $count = 1)

Добавить условие подсчёта/существования связи к запросу со "where" условиями.

Parameters

string $relation
Closure $callback
string $operator
int $count

Return Value

Builder|QueriesRelationships

Builder|QueriesRelationships orWhereHas(string $relation, Closure $callback = null, string $operator = '>=', int $count = 1)

Добавить условие подсчёта/существования связи к запросу со "where" условиями и оператором "или".

Parameters

string $relation
Closure $callback
string $operator
int $count

Return Value

Builder|QueriesRelationships

Builder|QueriesRelationships whereDoesntHave(string $relation, Closure $callback = null)

Добавить условие подсчёта/существования связи к запросу со "where" условиями.

Parameters

string $relation
Closure $callback

Return Value

Builder|QueriesRelationships

Builder|QueriesRelationships orWhereDoesntHave(string $relation, Closure $callback = null)

Добавить условие подсчёта/существования связи к запросу со "where" условиями и оператором "или".

Parameters

string $relation
Closure $callback

Return Value

Builder|QueriesRelationships

Builder|QueriesRelationships hasMorph(MorphTo|string $relation, string|array $types, string $operator = '>=', int $count = 1, string $boolean = 'and', Closure $callback = null)

Добавить условие подсчёта/существования полиморфной связи к запросу.

Parameters

MorphTo|string $relation
string|array $types
string $operator
int $count
string $boolean
Closure $callback

Return Value

Builder|QueriesRelationships

protected BelongsTo getBelongsToRelation(MorphTo $relation, string $type)

Получить связь BelongsTo для одного полиморфного типа.

Parameters

MorphTo $relation
string $type

Return Value

BelongsTo

Builder|QueriesRelationships orHasMorph(MorphTo|string $relation, string|array $types, string $operator = '>=', int $count = 1)

Добавить условие подсчёта/существования полиморфного отношения к запросу с "или".

Parameters

MorphTo|string $relation
string|array $types
string $operator
int $count

Return Value

Builder|QueriesRelationships

Builder|QueriesRelationships doesntHaveMorph(MorphTo|string $relation, string|array $types, string $boolean = 'and', Closure $callback = null)

Добавить условие подсчёта/существования полиморфного отношения к запросу.

Parameters

MorphTo|string $relation
string|array $types
string $boolean
Closure $callback

Return Value

Builder|QueriesRelationships

Builder|QueriesRelationships orDoesntHaveMorph(MorphTo|string $relation, string|array $types)

Добавить условие подсчёта/существования полиморфного отношения к запросу с "или".

Parameters

MorphTo|string $relation
string|array $types

Return Value

Builder|QueriesRelationships

Builder|QueriesRelationships whereHasMorph(MorphTo|string $relation, string|array $types, Closure $callback = null, string $operator = '>=', int $count = 1)

Добавить условие подсчёта/существования полиморфного отношения к запросу со встроенными условиями.

Parameters

MorphTo|string $relation
string|array $types
Closure $callback
string $operator
int $count

Return Value

Builder|QueriesRelationships

Builder|QueriesRelationships orWhereHasMorph(MorphTo|string $relation, string|array $types, Closure $callback = null, string $operator = '>=', int $count = 1)

Добавить условие подсчёта/существования полиморфного отношения к запросу со встроенными условиями и "или".

Parameters

MorphTo|string $relation
string|array $types
Closure $callback
string $operator
int $count

Return Value

Builder|QueriesRelationships

Builder|QueriesRelationships whereDoesntHaveMorph(MorphTo|string $relation, string|array $types, Closure $callback = null)

Добавить условие подсчёта/существования полиморфного отношения к запросу со встроенными условиями.

Parameters

MorphTo|string $relation
string|array $types
Closure $callback

Return Value

Builder|QueriesRelationships

Builder|QueriesRelationships orWhereDoesntHaveMorph(MorphTo|string $relation, string|array $types, Closure $callback = null)

Добавить условие подсчёта/существования полиморфного отношения к запросу со встроенными условиями и "или".

Parameters

MorphTo|string $relation
string|array $types
Closure $callback

Return Value

Builder|QueriesRelationships

Builder|QueriesRelationships whereRelation(string $relation, Closure|string|array|Expression $column, mixed $operator = null, mixed $value = null)

Добавить базовый предикат WHERE к запросу по отношению.

Parameters

string $relation
Closure|string|array|Expression $column
mixed $operator
mixed $value

Return Value

Builder|QueriesRelationships

Builder|QueriesRelationships orWhereRelation(string $relation, Closure|string|array|Expression $column, mixed $operator = null, mixed $value = null)

Добавить условие «или где» к запросу отношения.

Параметры

string $relation
Closure|string|array|Expression $column
mixed $operator
mixed $value

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

Builder|QueriesRelationships

Builder|QueriesRelationships whereMorphRelation(MorphTo|string $relation, string|array $types, Closure|string|array|Expression $column, mixed $operator = null, mixed $value = null)

Добавить условие полиморфного отношения к запросу с помощью условия «где».

Параметры

MorphTo|string $relation
string|array $types
Closure|string|array|Expression $column
mixed $operator
mixed $value

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

Builder|QueriesRelationships

Builder|QueriesRelationships orWhereMorphRelation(MorphTo|string $relation, string|array $types, Closure|string|array|Expression $column, mixed $operator = null, mixed $value = null)

Добавить условие полиморфного отношения к запросу с помощью условия «или где».

Параметры

MorphTo|string $relation
string|array $types
Closure|string|array|Expression $column
mixed $operator
mixed $value

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

Builder|QueriesRelationships

Builder|QueriesRelationships whereMorphedTo(MorphTo|string $relation, Model|string $model, $boolean = 'and')

Добавить условие отношения morph-to к запросу.

Параметры

MorphTo|string $relation
Model|string $model
$boolean

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

Builder|QueriesRelationships

Builder|QueriesRelationships orWhereMorphedTo(MorphTo|string $relation, Model|string $model)

Добавить условие отношения morph-to к запросу с помощью условия «или где».

Параметры

MorphTo|string $relation
Model|string $model

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

Builder|QueriesRelationships

$this whereBelongsTo(Model $related, $relationshipName = null, string $boolean = 'and')

Добавить условие отношения «принадлежит» к запросу.

Параметры

Model $related
$relationshipName
string $boolean

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

$this

Исключения

RuntimeException

$this orWhereBelongsTo(Model $related, $relationshipName = null)

Добавить отношение «BelongsTo» с условием «или где» к запросу.

Параметры

Model $related
$relationshipName

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

$this

Исключения

RuntimeException

$this withAggregate(mixed $relations, string $column, string $function = null)

Добавить подзапросы для включения агрегированного значения для отношения.

Параметры

mixed $relations
string $column
string $function

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

$this

$this withCount(mixed $relations)

Добавить подзапросы для подсчета отношений.

Параметры

mixed $relations

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

$this

$this withMax(string|array $relation, string $column)

Добавить подзапросы для включения максимального значения столбца отношения.

Параметры

string|array $relation
string $column

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

$this

$this withMin(string|array $relation, string $column)

Добавить подзапросы для включения минимального значения столбца отношения.

Параметры

string|array $relation
string $column

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

$this

$this withSum(string|array $relation, string $column)

Добавить подзапросы для включения суммы столбца отношения.

Параметры

string|array $relation
string $column

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

$this

$this withAvg(string|array $relation, string $column)

Добавить подзапросы для включения среднего значения столбца отношения.

Параметры

string|array $relation
string $column

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

$this

$this withExists(string|array $relation)

Добавить подзапросы для включения проверки существования связанных моделей.

Параметры

string|array $relation

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

$this

protected Builder|QueriesRelationships addHasWhere(Builder $hasQuery, Relation $relation, string $operator, int $count, string $boolean)

Добавить условие «has» в раздел where запроса.

Параметры

Builder $hasQuery
Relation $relation
string $operator
int $count
string $boolean

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

Builder|QueriesRelationships

Builder|QueriesRelationships mergeConstraintsFrom(Builder $from)

Объединить условия where из другого запроса в текущий запрос.

Параметры

Builder $from

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

Builder|QueriesRelationships

protected $this addWhereCountQuery(Builder $query, string $operator = '>=', int $count = 1, string $boolean = 'and')

Добавить условие подзапроса count к этому запросу.

Параметры

Builder $query
string $operator
int $count
string $boolean

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

$this

protected Relation getRelationWithoutConstraints(string $relation)

Получить базовый экземпляр запроса «has relation».

Параметры

string $relation

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

Relation

protected bool canUseExistsForExistenceCheck(string $operator, int $count)

Проверить, можем ли мы выполнить запрос «exists» для оптимизации производительности.

Параметры

string $operator
int $count

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

bool

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

Spec-Zone.ru

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