From 61ef78efa4fb8f77ac758b669c0f8f7f7ff00862 Mon Sep 17 00:00:00 2001 From: oddvalue Date: Fri, 13 Oct 2023 12:51:32 +0100 Subject: [PATCH 1/5] Exclude pages where `shouldRegisterNavigation()` is false --- src/Actions/RegisterPages.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Actions/RegisterPages.php b/src/Actions/RegisterPages.php index 3ecd595..caa351e 100644 --- a/src/Actions/RegisterPages.php +++ b/src/Actions/RegisterPages.php @@ -20,6 +20,10 @@ public static function boot(Panel $panel) */ $page = new $pageClass(); + if ($page::shouldRegisterNavigation() === false) { + continue; + } + $name = collect([ $page->getNavigationGroup(), $page->getTitle(), From 9786174243c64dafbac807192fcfb1285c814907 Mon Sep 17 00:00:00 2001 From: oddvalue Date: Wed, 3 Jan 2024 10:50:56 +0000 Subject: [PATCH 2/5] Update RegisterPages.php --- src/Actions/RegisterPages.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Actions/RegisterPages.php b/src/Actions/RegisterPages.php index caa351e..895a2c8 100644 --- a/src/Actions/RegisterPages.php +++ b/src/Actions/RegisterPages.php @@ -20,7 +20,7 @@ public static function boot(Panel $panel) */ $page = new $pageClass(); - if ($page::shouldRegisterNavigation() === false) { + if (method_exists($page, 'shouldRegisterSpotlight') && $page::shouldRegisterSpotlight() === false) { continue; } From 4168fbf35a58b22c513c5d6b23b256bac312c6dc Mon Sep 17 00:00:00 2001 From: oddvalue Date: Wed, 3 Jan 2024 10:56:29 +0000 Subject: [PATCH 3/5] Update readme.md --- readme.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/readme.md b/readme.md index 0523a99..5f7ebe8 100644 --- a/readme.md +++ b/readme.md @@ -79,6 +79,19 @@ CMD + / This plugin relies on the same properties and methods used for Filament's global search. For records showing up with the correct name in "Edit/View" you need to set `$recordTitleAttribute`. [Check the docs for more information](https://filamentphp.com/docs/2.x/admin/resources/global-search) +#### Excluding pages + +If you need to exclude a page from the spotlight results you may do so by adding a static `shouldRegisterSpotlight` method to the page and return false: + +```php +public static function shouldRegisterSpotlight(): bool +{ + return false; +} +``` + +This can be useful when you have pages that require URL parameters. + ## Translation To translate or edit the default placeholder, you have to publish the translation file for *wire-element/spotlight*: From 28f7e06fc97a221083d3671b088ba33c3fcaf3b8 Mon Sep 17 00:00:00 2001 From: Dennis Koch Date: Thu, 22 Feb 2024 08:00:44 +0100 Subject: [PATCH 4/5] #39 `shouldRegisterSpotlight()` for resources and resource pages --- src/Actions/RegisterResources.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Actions/RegisterResources.php b/src/Actions/RegisterResources.php index a720faa..2f660d0 100644 --- a/src/Actions/RegisterResources.php +++ b/src/Actions/RegisterResources.php @@ -13,10 +13,20 @@ public static function boot(Panel $panel) { $resources = $panel->getResources(); + + foreach ($resources as $resource) { + if (method_exists($resource, 'shouldRegisterSpotlight') && $resource::shouldRegisterSpotlight() === false) { + continue; + } + $pages = $resource::getPages(); foreach ($pages as $key => $page) { + if (method_exists($page->getPage(), 'shouldRegisterSpotlight') && $page->getPage()::shouldRegisterSpotlight() === false) { + continue; + } + /** * @var PageRegistration $page */ From 871ad8da73862a329d7769a75d68abcc8815b409 Mon Sep 17 00:00:00 2001 From: pxlrbt Date: Thu, 22 Feb 2024 07:02:43 +0000 Subject: [PATCH 5/5] Apply style changes --- src/Actions/RegisterResources.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Actions/RegisterResources.php b/src/Actions/RegisterResources.php index 2f660d0..2e47517 100644 --- a/src/Actions/RegisterResources.php +++ b/src/Actions/RegisterResources.php @@ -13,8 +13,6 @@ public static function boot(Panel $panel) { $resources = $panel->getResources(); - - foreach ($resources as $resource) { if (method_exists($resource, 'shouldRegisterSpotlight') && $resource::shouldRegisterSpotlight() === false) { continue;