Register Pages
Use the RegisterPages
provider to automatically register all your non-resource pages.
use pxlrbt\FilamentSpotlightPro\SpotlightPlugin;
use pxlrbt\FilamentSpotlightPro\SpotlightProviders\RegisterPages;
$panel->plugins([
SpotlightPlugin::make()->registerItems([
RegisterPages::make()
])
])
Excluding Pages
You can exclude pages by passing an array of page classes to the ->except()
. method.
SpotlightPlugin::make()->registerItems([
RegisterPages::make()->except([
Dashboard::class
])
])
You can also exclude pages by adding the static shouldRegisterSpotlight()
method to your Page class and return false
.
class Dashboard extends Page
{
public static function shouldRegisterSpotlight(): bool
{
return false;
}
}
Authorization
Spotlight uses canAccess()
method on your Page classes to determine if a user can view or access a page.
Default SpotlightResult
The RegisterPages
provider will automatically generate a SpotlightResult
for every page class that the current panel is aware of. It will use the page's navigation methods.
Custom SpotlightResult
Instead of the auto generated SpotlightResult
you can also create your own by adding the toSpotlightResult()
method to your Page class.
class Dashboard extends Page
{
public function toSpotlightResult(): SpotlightResult
{
return SpotlightResult::make()
->title('Dashboard')
->description('Your dashboard')
->icon('heroicon-o-home')
->route('dashboard');
}
}
You can also just modify the auto generated SpotlightResult
by adding the modifySpotlightResult()
method to your Page class.
class Dashboard extends Page
{
public function modifySpotlightResult(SpotlightResult $result): SpotlightResult
{
return $result->icon('heroicon-o-home');
}
}