https://github.com/howdu/filament-record-switcher
Resource title search with dropdown navigation for Filament
https://github.com/howdu/filament-record-switcher
filament filamentphp filamentphp-plugin laravel livewire php
Last synced: 3 months ago
JSON representation
Resource title search with dropdown navigation for Filament
- Host: GitHub
- URL: https://github.com/howdu/filament-record-switcher
- Owner: howdu
- License: mit
- Created: 2024-06-25T16:05:27.000Z (almost 2 years ago)
- Default Branch: 4.x
- Last Pushed: 2026-01-12T08:54:39.000Z (3 months ago)
- Last Synced: 2026-01-15T17:01:59.741Z (3 months ago)
- Topics: filament, filamentphp, filamentphp-plugin, laravel, livewire, php
- Language: PHP
- Homepage: https://filamentphp.com/plugins/howdu-record-switcher
- Size: 279 KB
- Stars: 14
- Watchers: 1
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
# Resource title navigation dropdown with search for Filament
[](https://packagist.org/packages/howdu/filament-record-switcher)
[](https://github.com/howdu/filament-record-switcher/actions?query=workflow%3Arun-tests+branch%3Amain)
[](https://packagist.org/packages/howdu/filament-record-switcher)

Subtly convert the page title into a dropdown navigation that's displayed on click.
It works similar to Filament's global search but only shows results for the current resource.
#### Compatibility
| Plugin Version | Filament Version | PHP Version |
|-------------------------------------------------------------------|------------------|-------------|
| [1.x](https://github.com/howdu/filament-record-switcher/tree/3.x) | 3.x | \> 8.1 |
| [2.x](https://github.com/howdu/filament-record-switcher/tree/4.x) | 4.x + 5.x | \> 8.2 |
## Installation
You can install the package via composer:
```bash
composer require howdu/filament-record-switcher
```
Optionally, you can publish the views using
```bash
php artisan vendor:publish --tag="filament-record-switcher-views"
```
## Usage
1. Register plugin inside your PanelProvider(s).
E.g `app/Filament/Providers/AdminPanelProvider.php`
```php
use Howdu\FilamentRecordSwitcher\FilamentRecordSwitcherPlugin;
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugin(
FilamentRecordSwitcherPlugin::make(),
);
}
}
```
2. Add the `HasRecordSwitcher` trait to each of your edit record Page.
E.g `app/Filament/Resources/Category/Pages/EditCategory.php`
```php
use Howdu\FilamentRecordSwitcher\Filament\Concerns\HasRecordSwitcher;
class EditCategory extends EditRecord
{
use HasRecordSwitcher;
}
```
Note: this trail will overwrite the `getHeading()` method if you've overwritten it in your Page you need to
overwrite `getRecordTitle()` instead.
If you want to add custom logic to the `afterSave()` method, you can do so by using the `recordSwitcherAfterSave()` method from the trait.
```php
use HasRecordSwitcher {
afterSave as recordSwitcherAfterSave;
}
protected function afterSave(): void
{
/// Custom logic
$this->recordSwitcherAfterSave();
}
````
3. Check your Resource class e.g CategoryResource has the record title attribute set which's used as the label in the select dropdown.
```php
protected static ?string $recordTitleAttribute = 'title';
```
4. Finally publish plugin assets.
```bash
php artisan filament:assets
```
## Testing
```bash
composer test
```
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.
## Security Vulnerabilities
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
## Credits
- [Ben J](https://github.com/howdu)
- [All Contributors](../../contributors)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.