Methods |
public
|
__construct(Builder $query): void
Create a new Eloquent query builder instance.
Create a new Eloquent query builder instance.
|
#
|
public
|
make(array $attributes = []): Model|static
Create and return an un-saved model instance.
Create and return an un-saved model instance.
|
#
|
public
|
withGlobalScope(string $identifier, Scope|Closure $scope): $this
Register a new global scope.
Register a new global scope.
|
#
|
public
|
withoutGlobalScope(Scope|string $scope): $this
Remove a registered global scope.
Remove a registered global scope.
|
#
|
public
|
withoutGlobalScopes(array|null $scopes = null): $this
Remove all or passed registered global scopes.
Remove all or passed registered global scopes.
|
#
|
public
|
removedScopes(): array
Get an array of global scopes that were removed from the query.
Get an array of global scopes that were removed from the query.
|
#
|
public
|
whereKey(mixed $id): $this
Add a where clause on the primary key to the query.
Add a where clause on the primary key to the query.
|
#
|
public
|
whereKeyNot(mixed $id): $this
Add a where clause on the primary key to the query.
Add a where clause on the primary key to the query.
|
#
|
public
|
where(
Closure|string|array|Expression $column,
mixed $operator = null,
mixed $value = null,
string $boolean = 'and',
): $this
Add a basic where clause to the query.
Add a basic where clause to the query.
|
#
|
public
|
firstWhere(
Closure|string|array|Expression $column,
mixed $operator = null,
mixed $value = null,
string $boolean = 'and',
): Model|static|null
Add a basic where clause to the query, and return the first result.
Add a basic where clause to the query, and return the first result.
|
#
|
public
|
orWhere(Closure|array|string|Expression $column, mixed $operator = null, mixed $value = null): $this
Add an "or where" clause to the query.
Add an "or where" clause to the query.
|
#
|
public
|
latest(string|Expression $column = null): $this
Add an "order by" clause for a timestamp to the query.
Add an "order by" clause for a timestamp to the query.
|
#
|
public
|
oldest(string|Expression $column = null): $this
Add an "order by" clause for a timestamp to the query.
Add an "order by" clause for a timestamp to the query.
|
#
|
public
|
hydrate(array $items): Collection
Create a collection of models from plain arrays.
Create a collection of models from plain arrays.
|
#
|
public
|
fromQuery(string $query, array $bindings = []): Collection
Create a collection of models from a raw query.
Create a collection of models from a raw query.
|
#
|
public
|
find(mixed $id, array $columns = ['*']): Model|Collection|static[]|static|null
Find a model by its primary key.
Find a model by its primary key.
|
#
|
public
|
findMany(Arrayable|array $ids, array $columns = ['*']): Collection
Find multiple models by their primary keys.
Find multiple models by their primary keys.
|
#
|
public
|
findOrFail(mixed $id, array $columns = ['*']): Model|Collection|static|static[]
Find a model by its primary key or throw an exception.
Find a model by its primary key or throw an exception.
Throws
|
#
|
public
|
findOrNew(mixed $id, array $columns = ['*']): Model|static
Find a model by its primary key or return fresh model instance.
Find a model by its primary key or return fresh model instance.
|
#
|
public
|
firstOrNew(array $attributes = [], array $values = []): Model|static
Get the first record matching the attributes or instantiate it.
Get the first record matching the attributes or instantiate it.
|
#
|
public
|
firstOrCreate(array $attributes = [], array $values = []): Model|static
Get the first record matching the attributes or create it.
Get the first record matching the attributes or create it.
|
#
|
public
|
updateOrCreate(array $attributes, array $values = []): Model|static
Create or update a record matching the attributes, and fill it with values.
Create or update a record matching the attributes, and fill it with values.
|
#
|
public
|
firstOrFail(array $columns = ['*']): Model|static
Execute the query and get the first result or throw an exception.
Execute the query and get the first result or throw an exception.
Throws
|
#
|
public
|
firstOr(Closure|array $columns = ['*'], Closure|null $callback = null): Model|static|mixed
Execute the query and get the first result or call a callback.
Execute the query and get the first result or call a callback.
|
#
|
public
|
sole(array|string $columns = ['*']): Model
Execute the query and get the first result if it's the sole matching record.
Execute the query and get the first result if it's the sole matching record.
Throws
|
#
|
public
|
value(string|Expression $column): mixed
Get a single column's value from the first result of a query.
Get a single column's value from the first result of a query.
|
#
|
public
|
valueOrFail(string|Expression $column): mixed
Get a single column's value from the first result of the query or throw an exception.
Get a single column's value from the first result of the query or throw an exception.
Throws
|
#
|
public
|
get(array|string $columns = ['*']): Collection|static[]
Execute the query as a "select" statement.
Execute the query as a "select" statement.
|
#
|
public
|
getModels(array|string $columns = ['*']): Model[]|static[]
Get the hydrated models without eager loading.
Get the hydrated models without eager loading.
|
#
|
public
|
eagerLoadRelations(array $models): array
Eager load the relationships for the models.
Eager load the relationships for the models.
|
#
|
public
|
getRelation(string $name): Relation
Get the relation instance for the given relation name.
Get the relation instance for the given relation name.
|
#
|
public
|
cursor(): LazyCollection
Get a lazy collection for the given query.
Get a lazy collection for the given query.
|
#
|
public
|
pluck(string|Expression $column, string|null $key = null): Collection
Get an array with the values of a given column.
Get an array with the values of a given column.
|
#
|
public
|
paginate(
int|null $perPage = null,
array $columns = ['*'],
string $pageName = 'page',
int|null $page = null,
): LengthAwarePaginator
Paginate the given query.
Paginate the given query.
Throws
|
#
|
public
|
simplePaginate(
int|null $perPage = null,
array $columns = ['*'],
string $pageName = 'page',
int|null $page = null,
): Paginator
Paginate the given query into a simple paginator.
Paginate the given query into a simple paginator.
|
#
|
public
|
cursorPaginate(
int|null $perPage = null,
array $columns = ['*'],
string $cursorName = 'cursor',
Cursor|string|null $cursor = null,
): CursorPaginator
Paginate the given query into a cursor paginator.
Paginate the given query into a cursor paginator.
|
#
|
public
|
create(array $attributes = []): Model|$this
Save a new model and return the instance.
Save a new model and return the instance.
|
#
|
public
|
forceCreate(array $attributes): Model|$this
Save a new model and return the instance. Allow mass-assignment.
Save a new model and return the instance. Allow mass-assignment.
|
#
|
public
|
update(array $values): int
Update records in the database.
Update records in the database.
|
#
|
public
|
upsert(array $values, array|string $uniqueBy, array|null $update = null): int
Insert new records or update the existing ones.
Insert new records or update the existing ones.
|
#
|
public
|
increment(string|Expression $column, float|int $amount = 1, array $extra = []): int
Increment a column's value by a given amount.
Increment a column's value by a given amount.
|
#
|
public
|
decrement(string|Expression $column, float|int $amount = 1, array $extra = []): int
Decrement a column's value by a given amount.
Decrement a column's value by a given amount.
|
#
|
public
|
delete(): mixed
Delete records from the database.
Delete records from the database.
|
#
|
public
|
forceDelete(): mixed
Run the default delete function on the builder.
Run the default delete function on the builder.
Since we do not apply scopes here, the row will actually be deleted.
|
#
|
public
|
onDelete(Closure $callback): void
Register a replacement for the default delete function.
Register a replacement for the default delete function.
|
#
|
public
|
hasNamedScope(string $scope): bool
Determine if the given model has a scope.
Determine if the given model has a scope.
|
#
|
public
|
scopes(array|string $scopes): static|mixed
Call the given local model scopes.
Call the given local model scopes.
|
#
|
public
|
applyScopes(): static
Apply the scopes to the Eloquent builder instance and return it.
Apply the scopes to the Eloquent builder instance and return it.
|
#
|
public
|
with(string|array $relations, string|Closure|null $callback = null): $this
Set the relationships that should be eager loaded.
Set the relationships that should be eager loaded.
|
#
|
public
|
without(mixed $relations): $this
Prevent the specified relations from being eager loaded.
Prevent the specified relations from being eager loaded.
|
#
|
public
|
withOnly(mixed $relations): $this
Set the relationships that should be eager loaded while removing any previously added eager loading specifications.
Set the relationships that should be eager loaded while removing any previously added eager loading specifications.
|
#
|
public
|
newModelInstance(array $attributes = []): Model|static
Create a new instance of the model being queried.
Create a new instance of the model being queried.
|
#
|
public
|
withCasts(array $casts): $this
Apply query-time casts to the model instance.
Apply query-time casts to the model instance.
|
#
|
public
|
getQuery(): Builder
Get the underlying query builder instance.
Get the underlying query builder instance.
|
#
|
public
|
setQuery(Builder $query): $this
Set the underlying query builder instance.
Set the underlying query builder instance.
|
#
|
public
|
toBase(): Builder
Get a base query builder instance.
Get a base query builder instance.
|
#
|
public
|
getEagerLoads(): array
Get the relationships being eagerly loaded.
Get the relationships being eagerly loaded.
|
#
|
public
|
setEagerLoads(array $eagerLoad): $this
Set the relationships being eagerly loaded.
Set the relationships being eagerly loaded.
|
#
|
public
|
getModel(): Model|static
Get the model instance being queried.
Get the model instance being queried.
|
#
|
public
|
setModel(Model $model): $this
Set a model instance for the model being queried.
Set a model instance for the model being queried.
|
#
|
public
|
qualifyColumn(string|Expression $column): string
Qualify the given column name by the model's table.
Qualify the given column name by the model's table.
|
#
|
public
|
qualifyColumns(array|Expression $columns): array
Qualify the given columns with the model's table.
Qualify the given columns with the model's table.
|
#
|
public
|
getMacro(string $name): Closure
Get the given macro by name.
Get the given macro by name.
|
#
|
public
|
hasMacro(string $name): bool
Checks if a macro is registered.
Checks if a macro is registered.
|
#
|
public
static
|
getGlobalMacro(string $name): Closure
Get the given global macro by name.
Get the given global macro by name.
|
#
|
public
static
|
hasGlobalMacro(string $name): bool
Checks if a global macro is registered.
Checks if a global macro is registered.
|
#
|
public
|
__get(string $key): mixed
Dynamically access builder proxies.
Dynamically access builder proxies.
Throws
|
#
|
public
|
__call(string $method, array $parameters): mixed
Dynamically handle calls into the query instance.
Dynamically handle calls into the query instance.
|
#
|
public
static
|
__callStatic(string $method, array $parameters): mixed
Dynamically handle calls into the query instance.
Dynamically handle calls into the query instance.
Throws
|
#
|
public
|
clone(): static
Clone the Eloquent query builder.
Clone the Eloquent query builder.
|
#
|
public
|
__clone(): void
Force a clone of the underlying query builder when cloning.
Force a clone of the underlying query builder when cloning.
|
#
|