Filament search improvements (non-Scout)#2269
Conversation
WalkthroughAdds searchable() or searchColumns() calls to multiple Filament table columns and relation selectors, disables Scout in the admin panel config, and documents the Scout and telemetry changes; no public method signatures or exported APIs were changed. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
packages/admin/src/Filament/Resources/DiscountResource/RelationManagers/ProductVariantLimitationRelationManager.php (1)
48-60: searchColumns(['sku']) is currently a no-op due to the custom getSearchResultsUsing overrideBecause getSearchResultsUsing is defined, the component won’t use the default query that respects ->searchColumns(['sku']). As a result, searching by SKU won’t work unless the callback itself includes an SKU condition.
Proposed fix: include SKU matching in the custom search and reduce result size.
Apply this diff:
- ->getSearchResultsUsing(static function (Forms\Components\Select $component, string $search): array { - $products = get_search_builder(Product::modelClass(), $search) - ->get(); - - return ProductVariant::whereIn('product_id', $products->pluck('id')) - ->with(['product']) - ->get() - ->mapWithKeys(fn (ProductVariantContract $record): array => [$record->getKey() => $record->product->attr('name').' - '.$record->sku]) - ->all(); - }) + ->getSearchResultsUsing(static function (Forms\Components\Select $component, string $search): array { + $productIds = get_search_builder(Product::modelClass(), $search) + ->pluck('id'); + + $variants = ProductVariant::query() + ->with('product') + ->where(function ($query) use ($productIds, $search) { + if ($productIds->isNotEmpty()) { + $query->whereIn('product_id', $productIds); + } + $query->orWhere('sku', 'like', '%' . $search . '%'); + }) + ->limit(50) + ->get(); + + return $variants + ->mapWithKeys(fn (ProductVariantContract $record): array => [ + $record->getKey() => $record->product->attr('name') . ' - ' . $record->sku, + ]) + ->all(); + })Optional enhancement: If you’d prefer to rely on Filament’s default search with ->searchColumns(['sku']) and still show “product name - sku” as the label, you can remove the getSearchResultsUsing override and instead use getOptionLabelFromRecordUsing on the Type:
- getOptionLabelFromRecordUsing(fn (ProductVariant $record) => $record->product->attr('name').' - '.$record->sku')
This keeps SKU-native searching and preserves the label format.
🧹 Nitpick comments (1)
packages/admin/src/Filament/Resources/DiscountResource/RelationManagers/CollectionLimitationRelationManager.php (1)
48-50: Verify JSON path search compatibility for attribute_data->namerecordSelectSearchColumns(['attribute_data->name']) may behave differently across databases:
- MySQL: where('json->path', 'like', ...) is generally supported but may match quoted JSON strings.
- PostgreSQL: text extraction typically requires ->> to unquote; LIKE on -> may not work as expected.
Please verify this works on all supported DB engines in Lunar. If cross-DB issues arise, consider a custom search callback using get_search_builder(Collection::class, $search) or narrowing to the current locale path (e.g., attribute_data->name->{locale}) where applicable.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these settings in your CodeRabbit configuration.
📒 Files selected for processing (5)
packages/admin/src/Filament/Resources/BrandResource.php(1 hunks)packages/admin/src/Filament/Resources/DiscountResource/RelationManagers/CollectionLimitationRelationManager.php(1 hunks)packages/admin/src/Filament/Resources/DiscountResource/RelationManagers/ProductVariantLimitationRelationManager.php(2 hunks)packages/admin/src/Filament/Resources/OrderResource.php(2 hunks)packages/admin/src/Filament/Resources/ProductOptionResource.php(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
- GitHub Check: admin - PHP 8.4 - L12.* ↑
- GitHub Check: shipping - PHP 8.4 - L12.* ↑ E
- GitHub Check: core - PHP 8.4 - L12.* ↑ E
- GitHub Check: core - PHP 8.4 - L12.* ↑
- GitHub Check: admin - PHP 8.4 - L12.* ↑ E
- GitHub Check: search - PHP 8.4 - L11.* ↑
- GitHub Check: shipping - PHP 8.4 - L11.* ↑
- GitHub Check: search - PHP 8.4 - L11.* ↑ E
- GitHub Check: stripe - PHP 8.3 - L12.* ↑
- GitHub Check: stripe - PHP 8.4 - L11.* ↑
- GitHub Check: admin - PHP 8.4 - L11.* ↑ E
- GitHub Check: admin - PHP 8.4 - L11.* ↑
- GitHub Check: core - PHP 8.4 - L11.* ↑ E
- GitHub Check: core - PHP 8.3 - L12.* ↑
- GitHub Check: admin - PHP 8.3 - L12.* ↑ E
- GitHub Check: core - PHP 8.3 - L12.* ↑ E
- GitHub Check: admin - PHP 8.3 - L11.* ↑ E
- GitHub Check: core - PHP 8.3 - L11.* ↑
- GitHub Check: core - PHP 8.3 - L11.* ↑ E
- GitHub Check: fix-code-style
🔇 Additional comments (6)
packages/admin/src/Filament/Resources/ProductOptionResource.php (1)
96-98: Making the translated name column searchable is a solid improvementThis aligns with the PR goal and should materially improve admin UX for large catalogs. No issues spotted.
packages/admin/src/Filament/Resources/BrandResource.php (1)
124-126: Enabling search on brand name: LGTMStraightforward and consistent with other resources. No concerns.
packages/admin/src/Filament/Resources/OrderResource.php (4)
99-101: Customer reference: searchable is appropriateThis improves operator workflows without side effects.
103-105: Confirm relation-scoped search columns are correctly prefixedFor TextColumn::make('billingAddress.fullName')->searchable(['first_name', 'last_name']), Filament may assume the relationship context. If not, this could miss the relation or cause ambiguous column errors. Prefer explicit prefixes to be safe.
Apply this diff for explicitness:
- ->searchable(['first_name', 'last_name']), + ->searchable(['billingAddress.first_name', 'billingAddress.last_name']),
118-121: Postcode: searchable is fineGood addition for narrowing down orders quickly by postcode.
126-128: Email: searchable and copy UX improvements look goodThe copyable and copy message duration changes are sensible and the column being searchable aligns with common workflows.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/admin/config/panel.php (1)
37-37: Make this flag environment-configurable for easier ops togglingAllow admins to switch behavior without editing published config by honoring an env var.
Apply this diff:
- 'scout_enabled' => false, + 'scout_enabled' => env('LUNAR_ADMIN_SCOUT_ENABLED', false),Optional follow-up: add a brief note in the comment above indicating the corresponding ENV key.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
packages/admin/config/panel.php(1 hunks)
🔇 Additional comments (1)
packages/admin/config/panel.php (1)
37-37: Confirmed — Scout disabled by default is intentional and properly gatedCode and tests show the config is read and Scout usage is guarded; docs reflect the default. No change required.
- packages/admin/config/panel.php — 'scout_enabled' => false
- packages/admin/src/helpers.php — checks config('lunar.panel.scout_enabled', false) and Searchable::class in get_search_builder()
- packages/admin/src/Support/Resources/BaseResource.php — checks config + Searchable before Scout global search
- packages/admin/src/Support/Pages/BaseListRecords.php — checks config + applies column searches
- tests/admin/Feature/... (BrandResource/Actions/SearchTest.php, GlobalSearchTest.php) — set Config::set('lunar.panel.scout_enabled', false)
- docs/core/installation.md — shows 'scout_enabled' => false
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
docs/core/upgrading.md (1)
38-46: Show opt-out usage in a concrete service provider context.Embedding the call in a typical Service Provider method reduces ambiguity for where to place it.
Apply this diff to replace the snippet with a complete example:
```php -\Lunar\Facades\Telemetry::optOut(); +public function register() +{ + \Lunar\Facades\Telemetry::optOut(); +}</blockquote></details> </blockquote></details> <details> <summary>📜 Review details</summary> **Configuration used: CodeRabbit UI** **Review profile: CHILL** **Plan: Pro** **💡 Knowledge Base configuration:** - MCP integration is disabled by default for public repositories - Jira integration is disabled by default for public repositories - Linear integration is disabled by default for public repositories You can enable these sources in your CodeRabbit configuration. <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between e6cd3df5ec846b0eedbd3cc2cf204c55a59bf61a and 9cd4dacf2c73eb800c3c31b86cdc48da23e44379. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `docs/core/upgrading.md` (1 hunks) </details> <details> <summary>🧰 Additional context used</summary> <details> <summary>🪛 LanguageTool</summary> <details> <summary>docs/core/upgrading.md</summary> [grammar] ~25-~25: There might be a mistake here. Context: ...#### Scout no longer enabled by default for admin panel With the recent panel searc... (QB_NEW_EN) </details> </details> </details> <details> <summary>⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)</summary> * GitHub Check: shipping - PHP 8.4 - L12.* ↑ * GitHub Check: admin - PHP 8.4 - L11.* ↑ E * GitHub Check: search - PHP 8.4 - L11.* ↑ * GitHub Check: stripe - PHP 8.4 - L12.* ↑ * GitHub Check: shipping - PHP 8.4 - L11.* ↑ * GitHub Check: search - PHP 8.4 - L12.* ↑ E * GitHub Check: admin - PHP 8.4 - L12.* ↑ * GitHub Check: admin - PHP 8.4 - L12.* ↑ E * GitHub Check: core - PHP 8.4 - L12.* ↑ * GitHub Check: admin - PHP 8.4 - L11.* ↑ * GitHub Check: core - PHP 8.4 - L11.* ↑ * GitHub Check: admin - PHP 8.3 - L12.* ↑ * GitHub Check: admin - PHP 8.3 - L12.* ↑ E * GitHub Check: core - PHP 8.3 - L12.* ↑ E * GitHub Check: shipping - PHP 8.3 - L11.* ↑ E * GitHub Check: admin - PHP 8.3 - L11.* ↑ * GitHub Check: core - PHP 8.3 - L11.* ↑ * GitHub Check: admin - PHP 8.3 - L11.* ↑ E * GitHub Check: core - PHP 8.3 - L11.* ↑ E * GitHub Check: fix-code-style </details> <details> <summary>🔇 Additional comments (1)</summary><blockquote> <details> <summary>docs/core/upgrading.md (1)</summary> `23-23`: **Section addition looks good.** Clear separation for “Medium Impact” is helpful for readers scanning the Unreleased changes. </details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
Improves non-Scout searching in a few areas.
Summary by CodeRabbit
New Features
Chores
Documentation