Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.x] Scout - Document 'makeSearchableUsing' method #8749

Merged
merged 2 commits into from
May 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions scout.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,21 @@ Or, if you already have a collection of Eloquent models in memory, you may call

$orders->searchable();

<a name="modifying-records-before-importing"></a>
#### Modifying Records Before Importing

Sometimes you may need to prepare the collection of models before they are made searchable. For instance, you may want to eager load a relationship so that the relationship data can be efficiently added to your search index. To accomplish this, define a `makeSearchableUsing` method on the corresponding model:

use Illuminate\Database\Eloquent\Collection;

/**
* Modify the collection of models being made searchable.
*/
protected function makeSearchableUsing(Collection $models): Collection
{
return $query->load('author');
}

<a name="removing-records"></a>
### Removing Records

Expand Down