fix scout search with soft deleted resource#2305
Merged
alecritson merged 15 commits intolunarphp:1.xfrom Apr 16, 2026
Merged
Conversation
wychoong
commented
Oct 6, 2025
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes Scout search functionality when working with soft-deleted models by properly applying trashed filters to Scout queries. The fix ensures that when users select "with trashed" or "only trashed" filters in Filament tables, the Scout search respects these filters by calling the appropriate methods (withTrashed() or onlyTrashed()) on the Scout builder.
Key changes:
- Added detection of Filament's
TrashedFilterstate inBaseListRecords.php - Applied
withTrashed()oronlyTrashed()to Scout queries based on filter state - Refactored query building code for improved readability and consistency
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
packages/core/src/LunarServiceProvider.php |
Updated orderBySequence macro to accept iterable instead of array and use blank() helper for better null-safety |
packages/admin/src/Support/Resources/BaseResource.php |
Simplified query building by removing unnecessary variables and consolidating method calls |
packages/admin/src/Support/Pages/BaseListRecords.php |
Added trashed filter detection and applied appropriate Scout methods to handle soft-deleted records |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
alecritson
reviewed
Apr 15, 2026
alecritson
approved these changes
Apr 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To use Scout search with soft delete model, as per laravel doc
and lunar also mentioned this in the doc
however this doesnt work when searching in the panel with filament table. when set to true, the scout search will not return the records, regardless the table filter already selected "with trashed" or "only trashed"
this PR attemp to fix this
p/s: this is just a quick fix, it might have a better way to detect is the with/only trashed filter is applied before using->with/onlyTrashedon the scout builder, to get a better search result.