interface SearchableInterface

Contract for models that can be indexed and searched.

This interface defines the public API that searchable models must implement. The Searchable trait provides a default implementation of these methods.

Methods

static Builder
search(string $query = '', Closure|null $callback = null)

Perform a search against the model's indexed data.

getScoutModelsByIds(Builder $builder, array $ids)

Get the requested models from an array of object IDs.

queryScoutModelsByIds(Builder $builder, array $ids)

Get a query builder for retrieving the requested models from an array of object IDs.

makeSearchableUsing(Collection $models)

Modify the collection of models being made searchable.

pushSoftDeleteMetadata()

Sync the soft deleted status for this model into the metadata.

searchableUsing()

Get the Scout engine for the model.

string|null
syncWithSearchUsing()

Get the queue connection that should be used when syncing.

string|null
syncWithSearchUsingQueue()

Get the queue that should be used with syncing.

void
searchable()

Make the given model instance searchable.

void
unsearchable()

Remove the given model instance from the search index.

string
searchableAs()

Get the index name for the model when searching.

string
indexableAs()

Get the index name for the model when indexing.

array
toSearchableArray()

Get the indexable data array for the model.

bool
shouldBeSearchable()

Determine if the model should be searchable.

mixed
getScoutKey()

Get the value used to index the model.

string
getScoutKeyName()

Get the key name used to index the model.

string
getScoutKeyType()

Get the auto-incrementing key type for querying models.

array
scoutMetadata()

Get all Scout related metadata.

withScoutMetadata(string $key, mixed $value)

Set a Scout related metadata.

Details

Perform a search against the model's indexed data.

Parameters

string $query
Closure|null $callback

Return Value

Builder

at line 31
Collection getScoutModelsByIds(Builder $builder, array $ids)

Get the requested models from an array of object IDs.

Parameters

Builder $builder
array $ids

Return Value

Collection

at line 36
Builder queryScoutModelsByIds(Builder $builder, array $ids)

Get a query builder for retrieving the requested models from an array of object IDs.

Parameters

Builder $builder
array $ids

Return Value

Builder

at line 41
Collection makeSearchableUsing(Collection $models)

Modify the collection of models being made searchable.

Parameters

Collection $models

Return Value

Collection

at line 48
SearchableInterface pushSoftDeleteMetadata()

Sync the soft deleted status for this model into the metadata.

Return Value

SearchableInterface

at line 53
Engine searchableUsing()

Get the Scout engine for the model.

Return Value

Engine

at line 58
string|null syncWithSearchUsing()

Get the queue connection that should be used when syncing.

Return Value

string|null

at line 63
string|null syncWithSearchUsingQueue()

Get the queue that should be used with syncing.

Return Value

string|null

at line 68
void searchable()

Make the given model instance searchable.

Return Value

void

at line 73
void unsearchable()

Remove the given model instance from the search index.

Return Value

void

at line 78
string searchableAs()

Get the index name for the model when searching.

Return Value

string

at line 83
string indexableAs()

Get the index name for the model when indexing.

Return Value

string

at line 88
array toSearchableArray()

Get the indexable data array for the model.

Return Value

array

at line 93
bool shouldBeSearchable()

Determine if the model should be searchable.

Return Value

bool

at line 98
mixed getScoutKey()

Get the value used to index the model.

Return Value

mixed

at line 103
string getScoutKeyName()

Get the key name used to index the model.

Return Value

string

at line 108
string getScoutKeyType()

Get the auto-incrementing key type for querying models.

Return Value

string

at line 113
array scoutMetadata()

Get all Scout related metadata.

Return Value

array

at line 120
SearchableInterface withScoutMetadata(string $key, mixed $value)

Set a Scout related metadata.

Parameters

string $key
mixed $value

Return Value

SearchableInterface