CollectionEngine
class CollectionEngine extends Engine
In-memory search engine using database queries and Collection filtering.
Useful for testing without requiring an external search service.
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.
Ensure that soft delete handling is properly applied to the query.
Get a Scout configuration value.
Details
at line 29
void
update(Collection $models)
Update the given models in the search index.
at line 37
void
delete(Collection $models)
Remove the given models from the search index.
at line 47
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 194
Collection
mapIds(mixed $results)
Pluck and return the primary keys of the given results.
at line 211
Collection
map(Builder $builder, mixed $results, Model $model)
Map the given results to instances of the given model.
at line 241
LazyCollection
lazyMap(Builder $builder, mixed $results, Model $model)
Map the given results to instances of the given model via a lazy collection.
at line 269
int
getTotalCount(mixed $results)
Get the total count from a raw result returned by the engine.
at line 277
void
flush(Model $model)
Flush all of the model's records from the engine.
at line 285
mixed
createIndex(string $name, array $options = [])
Create a search index.
at line 293
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 85
protected Collection
searchModels(Builder $builder)
Get the Eloquent models for the given builder.
at line 169
protected Builder
ensureSoftDeletesAreHandled(Builder $builder, Builder $query)
Ensure that soft delete handling is properly applied to the query.
The withTrashed/onlyTrashed/withoutTrashed methods are added dynamically by SoftDeletingScope. We guard these calls with runtime checks for SoftDeletes usage, making them safe but not statically analyzable.
at line 301
protected mixed
getScoutConfig(string $key, mixed $default = null)
Get a Scout configuration value.