Spec-Zone.ru › Laravel 9

Отношения запросов

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

Методы

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 withWhereHas(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)

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

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 whereNotMorphedTo(MorphTo|string $relation, Model|string $model, $boolean = 'and')

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

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

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

Builder|QueriesRelationships orWhereNotMorphedTo(MorphTo|string $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, string $column, string $function = null)

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

string getRelationHashedColumn(string $column, Relationship $relation)

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

$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" с помощью условия where к запросу.

Builder|QueriesRelationships mergeConstraintsFrom(Builder $from)

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

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

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

$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)

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

Параметры

string $relation
string $operator
int $count

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

Builder|QueriesRelationships

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

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

Параметры

string $relation
string $boolean
Closure $callback

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

Builder|QueriesRelationships

Builder|QueriesRelationships orDoesntHave(string $relation)

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

Параметры

string $relation

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

Builder|QueriesRelationships

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

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

Параметры

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

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

Builder|QueriesRelationships

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

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

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

Параметры

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

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

Builder|QueriesRelationships

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

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

Параметры

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

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

Builder|QueriesRelationships

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

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

Параметры

string $relation
Closure $callback

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

Builder|QueriesRelationships

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

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

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)

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

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)

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

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)

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

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)

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

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)

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

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)

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

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)

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

Parameters

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

Return Value

Builder|QueriesRelationships

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

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

Parameters

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

Return Value

Builder|QueriesRelationships

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

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

Parameters

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

Return Value

Builder|QueriesRelationships

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

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

Parameters

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

Return Value

Builder|QueriesRelationships
END_OF_DOCUMENT_MARKER

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

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

Параметры

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

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

Builder|QueriesRelationships

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

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

Параметры

MorphTo|string $relation
Model|string $model

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

Builder|QueriesRelationships

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

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

Параметры

MorphTo|string $relation
Model|string $model

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

Builder|QueriesRelationships

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

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

Параметры

Model|Model> $related
string|null $relationshipName
string $boolean

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

$this

Исключения

RelationNotFoundException

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

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

Параметры

Model $related
string|null $relationshipName

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

$this

Исключения

RuntimeException

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

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

Параметры

mixed $relations
string $column
string $function

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

$this

protected string getRelationHashedColumn(string $column, Relationship $relation)

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

Параметры

string $column
Relationship $relation

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

string

$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" в запрос.

Параметры

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

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

Builder|QueriesRelationships

Builder|QueriesRelationships mergeConstraintsFrom(Builder $from)

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

Параметры

Builder $from

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

Builder|QueriesRelationships

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 Relation getRelationWithoutConstraints(string $relation)

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

Параметры

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

Spec-Zone.ru

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