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

Defer to model's way of limiting the model set #292

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion src/Searchable/Aggregator.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,11 @@ public static function makeAllSearchable()
$softDeletes =
in_array(SoftDeletes::class, class_uses_recursive($model)) && config('scout.soft_delete', false);

$instance->newQuery()->when($softDeletes, function ($query) {
$instance->newQuery()
->when(true, function ($query) use ($instance) {
$instance->makeAllSearchableUsing($query);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This currently fails, since makeAllSearchableUsing is not available to call outside of the class: it's defined as a protected method in Laravel Scout. As long as it's protected, we can't use this method here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

laravel/scout#577

Thank you!

})
->when($softDeletes, function ($query) {
$query->withTrashed();
})->orderBy($instance->getKeyName())->chunk(config('scout.chunk.searchable', 500), function ($models) {
$models = $models->map(function ($model) {
Expand Down