Связи запросов
свойство Связи запросов (Просмотреть исходный код)
Методы
| 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)
Добавить условие подсчёта/существования отношения к запросу.
protected Builder|QueriesRelationships hasNested(string $relations, string $operator = '>=', int $count = 1, string $boolean = 'and', Closure|null $callback = null)
Добавить условия подсчёта/существования вложенных отношений к запросу.
Настраивает рекурсивный вызов whereHas до завершения вложенного отношения.
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)
Добавить условие подсчёта/существования полиморфной связи к запросу.
protected 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)
Добавить условие подсчёта/существования полиморфного отношения к запросу со встроенными условиями.
Builder|QueriesRelationships orWhereHasMorph(MorphTo|string $relation, string|array $types, Closure $callback = null, string $operator = '>=', int $count = 1)
Добавить условие подсчёта/существования полиморфного отношения к запросу со встроенными условиями и "или".
Builder|QueriesRelationships whereDoesntHaveMorph(MorphTo|string $relation, string|array $types, Closure $callback = null)
Добавить условие подсчёта/существования полиморфного отношения к запросу со встроенными условиями.
Builder|QueriesRelationships orWhereDoesntHaveMorph(MorphTo|string $relation, string|array $types, Closure $callback = null)
Добавить условие подсчёта/существования полиморфного отношения к запросу со встроенными условиями и "или".
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')
Добавить условие отношения «принадлежит» к запросу.
$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)
Добавить подзапросы для включения проверки существования связанных моделей.
protected Builder|QueriesRelationships addHasWhere(Builder $hasQuery, Relation $relation, string $operator, int $count, string $boolean)
Добавить условие «has» в раздел where запроса.
Builder|QueriesRelationships mergeConstraintsFrom(Builder $from)
Объединить условия where из другого запроса в текущий запрос.
protected $this addWhereCountQuery(Builder $query, string $operator = '>=', int $count = 1, string $boolean = 'and')
Добавить условие подзапроса count к этому запросу.
protected Relation getRelationWithoutConstraints(string $relation)
Получить базовый экземпляр запроса «has relation».
protected bool canUseExistsForExistenceCheck(string $operator, int $count)
Проверить, можем ли мы выполнить запрос «exists» для оптимизации производительности.
© 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