Spec-Zone.ru › Laravel 11

Запросы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)

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

Параметры

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

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

$this

Исключения

RuntimeException

protected $this 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

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

$this

$this orHas($relation, string $operator = '>=', int $count = 1)

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

Параметры

$relation
string $operator
int $count

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

$this

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

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

Параметры

$relation
string $boolean
Closure|null $callback

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

$this

$this orDoesntHave($relation)

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

Параметры

$relation

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

$this

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

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

Параметры

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

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

$this

$this withWhereHas($relation, Closure|null $callback = null, string $operator = '>=', int $count = 1)

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

Также загрузить связь с тем же условием.

Параметры

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

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

$this

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

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

Параметры

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

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

$this
END_OF_DOCUMENT_MARKER

$this whereDoesntHave($relation, Closure|null $callback = null)

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

Параметры

$relation
Closure|null $callback

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

$this

$this orWhereDoesntHave($relation, Closure|null $callback = null)

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

Параметры

$relation
Closure|null $callback

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

$this

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

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

Параметры

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

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

$this

protected TDeclaringModel> getBelongsToRelation(MorphTo $relation, TRelatedModel> $type)

Получить отношение BelongsTo для одного полиморфного типа.

Параметры

MorphTo $relation
TRelatedModel> $type

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

TDeclaringModel>

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

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

Параметры

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

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

$this

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

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

Параметры

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

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

$this

$this orDoesntHaveMorph($relation, string|array $types)

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

Параметры

$relation
string|array $types

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

$this

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

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

Параметры

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

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

$this

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

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

Параметры

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

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

$this

$this whereDoesntHaveMorph($relation, string|array $types, Closure|null $callback = null)

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

Параметры

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

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

$this

$this orWhereDoesntHaveMorph($relation, string|array $types, Closure|null $callback = null)

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

Параметры

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

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

$this

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

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

Параметры

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

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

$this

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

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

Параметры

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

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

$this

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

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

Параметры

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

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

$this

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

Добавить условие полиморфного отношения в запрос с помощью оператора "or where".

Параметры

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

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

$this

$this whereMorphedTo($relation, Модель|string|null $model, $boolean = 'and')

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

Параметры

$relation
Модель|string|null $model
$boolean

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

$this

$this whereNotMorphedTo($relation, Модель|string $model, $boolean = 'and')

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

Параметры

$relation
Модель|string $model
$boolean

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

$this

$this orWhereMorphedTo($relation, Модель|string|null $model)

Добавить условие отношения "morph-to" в запрос с помощью оператора "or where".

Параметры

$relation
Модель|string|null $model

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

$this

$this orWhereNotMorphedTo($relation, Модель|string $model)

Добавить условие отношения "not morph-to" в запрос с помощью оператора "or where".

Параметры

$relation
Модель|string $model

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

$this

$this whereBelongsTo(Модель|Модель> $related, string|null $relationshipName = null, string $boolean = 'and')

Добавить условие отношения "belongs to" в запрос с помощью оператора where.

Параметры

Модель|Модель> $related
string|null $relationshipName
string $boolean

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

$this

Исключения

RelationNotFoundException

$this orWhereBelongsTo(Модель $related, string|null $relationshipName = null)

Добавить условие отношения "BelongsTo" в запрос с помощью оператора "or where".

Параметры

Модель $related
string|null $relationshipName

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

$this

Исключения

RuntimeException

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

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

Параметры

mixed $relations
Expression|string $column
string $function

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

$this

protected string getRelationHashedColumn(string $column, $relation)

Получить имя хешированного столбца отношения для заданного столбца и отношения.

Параметры

string $column
$relation

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

string

$this withCount(mixed $relations)

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

Параметры

mixed $relations

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

$this

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

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

Параметры

string|array $relation
Expression|string $column

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

$this

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

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

Параметры

string|array $relation
Expression|string $column

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

$this

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

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

Параметры

string|array $relation
Expression|string $column

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

$this

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

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

Параметры

string|array $relation
Expression|string $column

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

$this

$this withExists(string|array $relation)

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

Параметры

string|array $relation

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

$this

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

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

Параметры

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

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

$this

$this mergeConstraintsFrom(Builder $from)

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

Параметры

Builder $from

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

$this

protected array requalifyWhereTables(array $wheres, string $from, string $to)

Обновляет имя таблицы для столбцов с новым квалифицированным именем.

Параметры

array $wheres
string $from
string $to

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

array

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

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

Параметры

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

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

$this

protected getRelationWithoutConstraints(string $relation)

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

Параметры

string $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/11.x/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.html

Spec-Zone.ru

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