DatabaseEngine
class DatabaseEngine extends Engine implements PaginatesEloquentModelsUsingDatabase
Database search engine implementation.
Searches directly in the database using LIKE queries and optional full-text search. This engine requires no external services and works with any database that Hypervel supports.
Properties
| protected Model>, array<class-string, string[]>> | $attributeColumns | Cached searchable attribute columns by model class and attribute class. |
|
| protected Model>, array<string, mixed>> | $fullTextOptions | Cached full-text options by model class. |
Methods
Pluck and return the primary keys of the given results.
Get the total count from a raw result returned by the engine.
Create a search index.
Delete a search index.
Pluck and return the primary keys of the given results using the given key name.
Paginate the given search on the engine using database pagination.
Paginate the given search on the engine using simple database pagination.
Get the Eloquent models for the given builder.
Build the initial text search database query for all relevant columns.
Add an "order by" clause that orders by relevance (Postgres only).
Add additional, developer defined constraints to the search query.
Ensure that soft delete constraints are properly applied to the query.
Get the columns marked with a given attribute.
Get a Scout configuration value.
Details
at line 482
void
update(Collection $models)
Update the given models in the search index.
The database engine doesn't need to update an external index.
at line 494
void
delete(Collection $models)
Remove the given models from the search index.
The database engine doesn't need to remove from an external index.
at line 54
mixed
search(Builder $builder)
Perform a search against the engine.
at line 69
mixed
paginate(Builder $builder, int $perPage, int $page)
Perform a paginated search against the engine.
at line 433
Collection
mapIds(mixed $results)
Pluck and return the primary keys of the given results.
at line 449
Collection
map(Builder $builder, mixed $results, Model $model)
Map the given results to instances of the given model.
at line 459
LazyCollection
lazyMap(Builder $builder, mixed $results, Model $model)
Map the given results to instances of the given model via a lazy collection.
at line 470
int
getTotalCount(mixed $results)
Get the total count from a raw result returned by the engine.
at line 504
void
flush(Model $model)
Flush all of the model's records from the engine.
at line 512
mixed
createIndex(string $name, array $options = [])
Create a search index.
at line 521
mixed
deleteIndex(string $name)
Delete a search index.
in
Engine at line 90
Collection
mapIdsFrom(mixed $results, string $key)
Pluck and return the primary keys of the given results using the given key name.
in
Engine at line 98
Collection
keys(Builder $builder)
Get the results of the query as a Collection of primary keys.
in
Engine at line 106
Collection
get(Builder $builder)
Get the results of the given query mapped onto models.
in
Engine at line 118
LazyCollection
cursor(Builder $builder)
Get a lazy collection for the given query mapped onto models.
at line 82
LengthAwarePaginator
paginateUsingDatabase(Builder $builder, int $perPage, string $pageName, int $page)
Paginate the given search on the engine using database pagination.
at line 109
Paginator
simplePaginateUsingDatabase(Builder $builder, int $perPage, string $pageName, int $page)
Paginate the given search on the engine using simple database pagination.
at line 138
protected Collection
searchModels(Builder $builder, int|null $page = null, int|null $perPage = null)
Get the Eloquent models for the given builder.
at line 165
protected Builder
buildSearchQuery(Builder $builder)
Initialize / build the search query for the given Scout builder.
at line 189
protected Builder
initializeSearchQuery(Builder $builder, array $columns, array $prefixColumns = [], array $fullTextColumns = [])
Build the initial text search database query for all relevant columns.
at line 255
protected bool
shouldOrderByRelevance(Builder $builder)
Determine if the query should be ordered by relevance.
at line 267
protected Builder
orderByRelevance(Builder $builder, Builder $query)
Add an "order by" clause that orders by relevance (Postgres only).
at line 298
protected Builder
addAdditionalConstraints(Builder $builder, Builder $query)
Add additional, developer defined constraints to the search query.
at line 329
protected Builder
constrainForSoftDeletes(Builder $builder, Builder $query)
Ensure that soft delete constraints are properly applied to the query.
at line 361
protected array
getFullTextColumns(Builder $builder)
Get the full-text columns for the query.
at line 371
protected array
getPrefixColumns(Builder $builder)
Get the prefix search columns for the query.
at line 382
protected array
getAttributeColumns(Builder $builder, string $attributeClass)
Get the columns marked with a given attribute.
at line 410
protected array
getFullTextOptions(Builder $builder)
Get the full-text search options for the query.
at line 530
protected mixed
getConfig(string $key, mixed $default = null)
Get a Scout configuration value.