filament-plugin-tools

Can Globally Search

Global Search

you can let your user customize the Global Search for a resource

to implement this, add the trait to yor plugin:

1class MyAwesomePlugin extends FilamentPluginTools implements Plugin
2{
3 use CanGloballySearch;
4}

and defined the default searches:

1public array $defaultGloballySearchableAttributes = [
2 AwesomeResource::class => ['title', 'slug'],
3];

in your resource you can get the configuration like:

1public static function getGloballySearchableAttributes(): array
2{
3 return MyAwesomePlugin::get()->getGlobalAttributes(static::class);
4}

Now, your users can configure the global search in the panel:

1public function panel(Panel $panel): Panel
2{
3 return $panel
4 // ...
5 ->plugins([
6 MyAwesomePlugin::make()
7 ->globallySearchableAttributes(['title', 'slug']),
8 ]);
9}

Diable Global Search

uses may disable global search by using disableGlobalSearch:

1public function panel(Panel $panel): Panel
2{
3 return $panel
4 // ...
5 ->plugins([
6 MyAwesomePlugin::make()
7 ->disableGlobalSearch([
8 LinksResource::class
9 ]),
10 ]);
11}

Zeus is an open-source project. Thanks to my sponsors for helping me maintain this project.