Skip to content

Register Pages ​

Use the RegisterPages provider to automatically register all your non-resource pages.

php
use pxlrbt\FilamentSpotlightPro\SpotlightPlugin;
use pxlrbt\FilamentSpotlightPro\SpotlightProviders\RegisterPages;

$panel->plugins([
    SpotlightPlugin::make()->registerItems([
        RegisterPages::make()
    ])
])

Showing Pages Across Panels ​

By default, Pages shown in Filament Spotlight Pro will be restricted to the current panel. You can enable showing Pages from other panels via the->fromPanels() method.

php
SpotlightPlugin::make()->registerItems([
    RegisterPages::make()->fromPanels([
        'admin', 'backend'
    ])
])

If you want to show Pages from all panels use ->fromAllPanels(). You can additionally exclude single panels, by passing the except: param.

php
SpotlightPlugin::make()->registerItems([
    RegisterPages::make()->fromAllPanels(except: ['superadmin'])
])

Excluding Pages ​

You can exclude pages by passing an array of page classes to the ->except(). method.

php
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.

php
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.

php
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.

php
class Dashboard extends Page
{
    public function modifySpotlightResult(SpotlightResult $result): SpotlightResult
    {
        return $result->icon('heroicon-o-home');
    }
}

Adding Search Aliases ​

Similarly to Resources, you can add search aliases to Pages to improve their discoverability. Implement the static getSpotlightAliases(): array method in your Page class.

The search logic and display behavior are identical to resource aliases: all aliases are searchable, and the first one in the array is displayed next to the page's title in the results.

php
class ViewReports extends Page
{
    protected static ?string $title = 'Reports';

    public static function getSpotlightAliases(): array
    {
        return ['statistics', 'analytics', 'data'];
    }
}