ЗапросыRelationships
атрибут ЗапросыRelationships mixin Builder (View source)
Методы
| $this | has($relation, string $operator = '>=', int $count = 1, string $boolean = 'and', Closure|null $callback = null) Добавить условие подсчета/существования отношения к запросу. | |
| $this | hasNested(string $relations, string $operator = '>=', int $count = 1, string $boolean = 'and', Closure|null $callback = null) Добавить условия подсчета/существования вложенных отношений к запросу. | |
| $this | orHas($relation, string $operator = '>=', int $count = 1) Добавить условие подсчета/существования отношения к запросу с "или". | |
| $this | doesntHave($relation, string $boolean = 'and', Closure|null $callback = null) Добавить условие подсчета/отсутствия отношения к запросу. | |
| $this | orDoesntHave($relation) Добавить условие подсчета/отсутствия отношения к запросу с "или". | |
| $this | whereHas($relation, Closure|null $callback = null, string $operator = '>=', int $count = 1) Добавить условие подсчета/существования отношения к запросу с условиями where. | |
| $this | withWhereHas($relation, Closure|null $callback = null, string $operator = '>=', int $count = 1) Добавить условие подсчета/существования отношения к запросу с условиями where. | |
| $this | orWhereHas($relation, Closure|null $callback = null, string $operator = '>=', int $count = 1) Добавить условие подсчета/существования отношения к запросу с условиями where и "или". | |
| $this | whereDoesntHave($relation, Closure|null $callback = null) Добавить условие подсчета/отсутствия отношения к запросу с условиями where. | |
| $this | orWhereDoesntHave($relation, Closure|null $callback = null) Добавить условие подсчета/отсутствия отношения к запросу с условиями where и "или". | |
| $this | hasMorph($relation, string|array $types, string $operator = '>=', int $count = 1, string $boolean = 'and', Closure|null $callback = null) Добавить условие полиморфного подсчета/существования отношения к запросу. | |
| TDeclaringModel> | getBelongsToRelation(MorphTo $relation, TRelatedModel> $type) Получить отношение BelongsTo для одного полиморфного типа. | |
| $this | orHasMorph($relation, string|array $types, string $operator = '>=', int $count = 1) Добавить условие полиморфного подсчета/существования отношения к запросу с "или". | |
| $this | doesntHaveMorph($relation, string|array $types, string $boolean = 'and', Closure|null $callback = null) Добавить условие полиморфного подсчета/отсутствия отношения к запросу. | |
| $this | orDoesntHaveMorph($relation, string|array $types) Добавить условие полиморфного подсчета/отсутствия отношения к запросу с "или". | |
| $this | whereHasMorph($relation, string|array $types, Closure|null $callback = null, string $operator = '>=', int $count = 1) Добавить условие полиморфного подсчета/существования отношения к запросу с условиями where. | |
| $this | orWhereHasMorph($relation, string|array $types, Closure|null $callback = null, string $operator = '>=', int $count = 1) Добавить условие полиморфного подсчета/существования отношения к запросу с условиями where и "или". | |
| $this | whereDoesntHaveMorph($relation, string|array $types, Closure|null $callback = null) Добавить условие полиморфного подсчета/отсутствия отношения к запросу с условиями where. | |
| $this | orWhereDoesntHaveMorph($relation, string|array $types, Closure|null $callback = null) Добавить условие полиморфного подсчета/отсутствия отношения к запросу с условиями where и "или". | |
| $this | whereRelation($relation, Closure|string|array|Expression $column, mixed $operator = null, mixed $value = null) Добавить базовое условие where к запросу отношения. | |
| $this | orWhereRelation($relation, Closure|string|array|Expression $column, mixed $operator = null, mixed $value = null) Добавить условие "или где" к запросу отношения. | |
| $this | whereMorphRelation($relation, string|array $types, Closure|string|array|Expression $column, mixed $operator = null, mixed $value = null) Добавить условие полиморфного отношения к запросу с условием where. | |
| $this | orWhereMorphRelation($relation, string|array $types, Closure|string|array|Expression $column, mixed $operator = null, mixed $value = null) Добавить условие полиморфного отношения к запросу с условием "или где". | |
| $this | whereMorphedTo($relation, Model|string|null $model, $boolean = 'and') Добавить условие отношения morph-to к запросу. | |
| $this | whereNotMorphedTo($relation, Model|string $model, $boolean = 'and') Добавить условие отношения не morph-to к запросу. | |
| $this | orWhereMorphedTo($relation, Model|string|null $model) Добавить условие отношения morph-to к запросу с "или где". | |
| $this | orWhereNotMorphedTo($relation, Model|string $model) Добавить условие отношения не morph-to к запросу с "или где". | |
| $this | whereBelongsTo(Model|Model> $related, string|null $relationshipName = null, string $boolean = 'and') Добавить условие отношения "belongs to" к запросу. | |
| $this | orWhereBelongsTo(Model $related, string|null $relationshipName = null) Добавить условие отношения "BelongsTo" с "или где" к запросу. |
| $this | withAggregate(mixed $relations, Expression|string $column, string $function = null)
Добавить подзапросы для включения агрегированного значения для связи. | |
| string | getRelationHashedColumn(string $column, $relation)
Получить имя хэшированного столбца связи для заданного столбца и связи. | |
| $this | withCount(mixed $relations)
Добавить подзапросы для подсчета связей. | |
| $this | withMax(string|array $relation, Expression|string $column)
Добавить подзапросы для включения максимального значения столбца связи. | |
| $this | withMin(string|array $relation, Expression|string $column)
Добавить подзапросы для включения минимального значения столбца связи. | |
| $this | withSum(string|array $relation, Expression|string $column)
Добавить подзапросы для включения суммы значений столбца связи. | |
| $this | withAvg(string|array $relation, Expression|string $column)
Добавить подзапросы для включения среднего значения столбца связи. | |
| $this | withExists(string|array $relation)
Добавить подзапросы для проверки существования связанных моделей. | |
| $this | addHasWhere(Builder $hasQuery, Relation $relation, string $operator, int $count, string $boolean)
Добавить условие "has" в запрос. | |
| $this | mergeConstraintsFrom(Builder $from)
Объединить условия where из другого запроса в текущий запрос. | |
| array | requalifyWhereTables(array $wheres, string $from, string $to)
Обновляет имя таблицы для столбцов с новым квалифицированным именем. | |
| $this | addWhereCountQuery(Builder $query, string $operator = '>=', int $count = 1, string $boolean = 'and')
Добавить подзапрос count в текущий запрос. | |
| getRelationWithoutConstraints(string $relation)
Получить базовый экземпляр запроса для "has relation". | ||
| bool | canUseExistsForExistenceCheck(string $operator, int $count)
Проверить, можем ли мы выполнить запрос "exists" для оптимизации производительности. |
Подробности
$this has($relation, string $operator = '>=', int $count = 1, string $boolean = 'and', Closure|null $callback = null)
Добавить условие подсчета/существования связи в запрос.
protected $this hasNested(string $relations, string $operator = '>=', int $count = 1, string $boolean = 'and', Closure|null $callback = null)
Добавить условия подсчета/существования вложенных связей в запрос.
Настраивает рекурсивный вызов whereHas, пока не завершим вложенную связь.
$this orHas($relation, string $operator = '>=', int $count = 1)
Добавить условие подсчета/существования связи в запрос с "or".
$this doesntHave($relation, string $boolean = 'and', Closure|null $callback = null)
Добавить условие подсчета/существования связи в запрос.
$this orDoesntHave($relation)
Добавить условие подсчета/существования связи в запрос с "or".
$this whereHas($relation, Closure|null $callback = null, string $operator = '>=', int $count = 1)
Добавить условие подсчета/существования связи в запрос с условиями where.
$this withWhereHas($relation, Closure|null $callback = null, string $operator = '>=', int $count = 1)
Добавить условие подсчета/существования связи в запрос с условиями where.
Также загрузить связь с тем же условием.
$this orWhereHas($relation, Closure|null $callback = null, string $operator = '>=', int $count = 1)
Добавить условие подсчета/существования связи в запрос с условиями where и "or".
$this whereDoesntHave($relation, Closure|null $callback = null)
Добавить условие подсчёта/существования отношения к запросу с условиями where.
$this orWhereDoesntHave($relation, Closure|null $callback = null)
Добавить условие подсчёта/существования отношения к запросу с условиями where и оператором "или".
$this hasMorph($relation, string|array $types, string $operator = '>=', int $count = 1, string $boolean = 'and', Closure|null $callback = null)
Добавить условие подсчёта/существования полиморфного отношения к запросу.
protected TDeclaringModel> getBelongsToRelation(MorphTo $relation, TRelatedModel> $type)
Получить отношение BelongsTo для одного полиморфного типа.
$this orHasMorph($relation, string|array $types, string $operator = '>=', int $count = 1)
Добавить условие подсчёта/существования полиморфного отношения к запросу с оператором "или".
$this doesntHaveMorph($relation, string|array $types, string $boolean = 'and', Closure|null $callback = null)
Добавить условие подсчёта/существования полиморфного отношения к запросу.
$this orDoesntHaveMorph($relation, string|array $types)
Добавить условие подсчёта/существования полиморфного отношения к запросу с оператором "или".
$this whereHasMorph($relation, string|array $types, Closure|null $callback = null, string $operator = '>=', int $count = 1)
Добавить условие подсчёта/существования полиморфного отношения к запросу с условиями where.
$this orWhereHasMorph($relation, string|array $types, Closure|null $callback = null, string $operator = '>=', int $count = 1)
Добавить условие подсчёта/существования полиморфного отношения к запросу с условиями where и оператором "или".
$this whereDoesntHaveMorph($relation, string|array $types, Closure|null $callback = null)
Добавить условие подсчёта/существования полиморфного отношения к запросу с условиями where.
$this orWhereDoesntHaveMorph($relation, string|array $types, Closure|null $callback = null)
Добавить условие подсчёта/существования полиморфного отношения к запросу с условиями where и оператором "или".
$this whereRelation($relation, Closure|string|array|Expression $column, mixed $operator = null, mixed $value = null)
Добавить базовое условие where к запросу отношения.
$this orWhereRelation($relation, Closure|string|array|Expression $column, mixed $operator = null, mixed $value = null)
Добавить условие "или где" к запросу отношения.
$this whereMorphRelation($relation, string|array $types, Closure|string|array|Expression $column, mixed $operator = null, mixed $value = null)
Добавить условие полиморфного отношения в запрос с помощью оператора where.
$this orWhereMorphRelation($relation, string|array $types, Closure|string|array|Expression $column, mixed $operator = null, mixed $value = null)
Добавить условие полиморфного отношения в запрос с помощью оператора "or where".
$this whereMorphedTo($relation, Модель|string|null $model, $boolean = 'and')
Добавить условие отношения "morph-to" в запрос.
$this whereNotMorphedTo($relation, Модель|string $model, $boolean = 'and')
Добавить условие отношения "not morph-to" в запрос.
$this orWhereMorphedTo($relation, Модель|string|null $model)
Добавить условие отношения "morph-to" в запрос с помощью оператора "or where".
$this orWhereNotMorphedTo($relation, Модель|string $model)
Добавить условие отношения "not morph-to" в запрос с помощью оператора "or where".
$this whereBelongsTo(Модель|Модель> $related, string|null $relationshipName = null, string $boolean = 'and')
Добавить условие отношения "belongs to" в запрос с помощью оператора where.
$this orWhereBelongsTo(Модель $related, string|null $relationshipName = null)
Добавить условие отношения "BelongsTo" в запрос с помощью оператора "or where".
$this withAggregate(mixed $relations, Expression|string $column, string $function = null)
Добавить подзапросы для включения агрегированного значения для отношения.
protected string getRelationHashedColumn(string $column, $relation)
Получить имя хешированного столбца отношения для заданного столбца и отношения.
$this withCount(mixed $relations)
Добавить подзапросы для подсчета отношений.
$this withMax(string|array $relation, Expression|string $column)
Добавить подзапросы для включения максимального значения столбца отношения.
$this withMin(string|array $relation, Expression|string $column)
Добавить подзапросы для включения минимального значения столбца отношения.
$this withSum(string|array $relation, Expression|string $column)
Добавить подзапросы для включения суммы столбца отношения.
$this withAvg(string|array $relation, Expression|string $column)
Добавить подзапросы для включения среднего значения столбца отношения.
$this withExists(string|array $relation)
Добавить подзапросы для включения существования связанных моделей.
protected $this addHasWhere(Builder $hasQuery, Relation $relation, string $operator, int $count, string $boolean)
Добавить условие "has" к запросу.
$this mergeConstraintsFrom(Builder $from)
Объединить условия where из другого запроса в текущий запрос.
protected array requalifyWhereTables(array $wheres, string $from, string $to)
Обновляет имя таблицы для столбцов с новым квалифицированным именем.
protected $this addWhereCountQuery(Builder $query, string $operator = '>=', int $count = 1, string $boolean = 'and')
Добавить условие подзапроса количества в текущий запрос.
protected 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/11.x/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.html