### Install Filament Refresh Sidebar via Composer Source: https://github.com/jeffersongoncalves/filament-refresh-sidebar/blob/2.x/README.md Install the package via Composer. Requires PHP 8.2 or higher and Filament 5.0. ```bash composer require jeffersongoncalves/filament-refresh-sidebar ``` -------------------------------- ### Run Static Analysis and Format Code Source: https://github.com/jeffersongoncalves/filament-refresh-sidebar/blob/2.x/README.md Development commands for code analysis and formatting. Run 'composer analyse' for static analysis and 'composer format' to format code. ```bash # Run static analysis composer analyse # Format code composer format ``` -------------------------------- ### RefreshSidebarServiceProvider with hasViews Source: https://github.com/jeffersongoncalves/filament-refresh-sidebar/blob/2.x/resources/boost/skills/filament-refresh-sidebar-development/SKILL.md The service provider registers the package views using Spatie Laravel Package Tools. ```php namespace JeffersonGoncalves\Filament\RefreshSidebar; use Spatie\LaravelPackageTools\Package; use Spatie\LaravelPackageTools\PackageServiceProvider; class RefreshSidebarServiceProvider extends PackageServiceProvider { public function configurePackage(Package $package): void { $package->name('filament-refresh-sidebar') ->hasViews(); } } ``` -------------------------------- ### Register RefreshSidebarPlugin in PanelProvider Source: https://github.com/jeffersongoncalves/filament-refresh-sidebar/blob/2.x/resources/boost/skills/filament-refresh-sidebar-development/SKILL.md Register the RefreshSidebarPlugin in your PanelProvider. No configuration files are needed. ```php use JeffersonGoncalves\Filament\RefreshSidebar\RefreshSidebarPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ RefreshSidebarPlugin::make(), ]); } ``` -------------------------------- ### Register RefreshSidebarPlugin in Filament Panel Provider Source: https://github.com/jeffersongoncalves/filament-refresh-sidebar/blob/2.x/README.md Register the plugin in your Filament Panel Provider, typically app/Providers/Filament/AdminPanelProvider.php. Add the plugin to the plugins array to enable automatic sidebar refresh. ```php use JeffersonGoncalves\Filament\RefreshSidebar\RefreshSidebarPlugin; public function panel(Panel $panel): Panel { return $panel // ... other configuration ->plugins([ RefreshSidebarPlugin::make(), ]); } ``` -------------------------------- ### Refresh sidebar after creating a record Source: https://github.com/jeffersongoncalves/filament-refresh-sidebar/blob/2.x/resources/boost/skills/filament-refresh-sidebar-development/SKILL.md Dispatch the 'refresh-sidebar' event after creating a record to update the sidebar. ```php protected function afterCreate(): void { $this->dispatch('refresh-sidebar'); } ``` -------------------------------- ### RefreshSidebarPlugin class with render hook registration Source: https://github.com/jeffersongoncalves/filament-refresh-sidebar/blob/2.x/resources/boost/skills/filament-refresh-sidebar-development/SKILL.md The plugin class registers a JavaScript snippet via PanelsRenderHook::SCRIPTS_AFTER. It implements the Filament Plugin contract and returns the plugin ID 'filament-refresh-sidebar'. ```php namespace JeffersonGoncalves\Filament\RefreshSidebar; use Filament\Contracts\Plugin; use Filament\Panel; use Filament\View\PanelsRenderHook; use Illuminate\Contracts\View\View; class RefreshSidebarPlugin implements Plugin { public static function make(): static { return app(static::class); } public function getId(): string { return 'filament-refresh-sidebar'; } public function register(Panel $panel): void { $panel->renderHook( PanelsRenderHook::SCRIPTS_AFTER, fn (): View => view('filament-refresh-sidebar::scripts') ); } public function boot(Panel $panel): void {} } ``` -------------------------------- ### Dispatch refresh-sidebar Event from Livewire Component Source: https://github.com/jeffersongoncalves/filament-refresh-sidebar/blob/2.x/README.md Manually trigger a sidebar refresh from any Livewire component by dispatching the 'refresh-sidebar' event. Useful for updating navigation badges after custom actions like creating, updating, or deleting records. ```php $this->dispatch('refresh-sidebar'); ``` -------------------------------- ### Refresh sidebar after deleting a record Source: https://github.com/jeffersongoncalves/filament-refresh-sidebar/blob/2.x/resources/boost/skills/filament-refresh-sidebar-development/SKILL.md Dispatch the 'refresh-sidebar' event after deleting a record to update the sidebar. ```php protected function afterDelete(): void { $this->dispatch('refresh-sidebar'); } ``` -------------------------------- ### Refresh sidebar after a custom action Source: https://github.com/jeffersongoncalves/filament-refresh-sidebar/blob/2.x/resources/boost/skills/filament-refresh-sidebar-development/SKILL.md Dispatch the 'refresh-sidebar' event after a custom action, such as an approval action. ```php use Filament\Actions\Action; Action::make('approve') ->action(function () { // ... approval logic $this->dispatch('refresh-sidebar'); }), ``` -------------------------------- ### Refresh sidebar after updating a record Source: https://github.com/jeffersongoncalves/filament-refresh-sidebar/blob/2.x/resources/boost/skills/filament-refresh-sidebar-development/SKILL.md Dispatch the 'refresh-sidebar' event after updating a record to refresh the sidebar. ```php protected function afterSave(): void { $this->dispatch('refresh-sidebar'); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.