bambamboole / filament-menu
Create menus with ease in Filament
Fund package maintenance!
bambamboole
Installs: 117
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/bambamboole/filament-menu
Requires
- php: ^8.3
- filament/filament: ^5.0
- spatie/laravel-package-tools: ^1.15.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.0
- nunomaduro/collision: ^8.0
- orchestra/testbench: ^9.0|^10.0
- pestphp/pest: ^3.7|^4.0
- pestphp/pest-plugin-arch: ^3.0|^4.0
- pestphp/pest-plugin-laravel: ^3.0|^4.0
- pestphp/pest-plugin-livewire: ^3.0|^4.0
- rector/rector: ^2.0
README
A menu builder plugin for Filament that lets you create and manage navigation menus with drag-and-drop ordering, nesting, and linkable Eloquent models.
Installation
composer require bambamboole/filament-menu
Add the plugin views to your custom theme's CSS file:
@source '../../../../vendor/bambamboole/filament-menu/resources/**/*.blade.php';
Usage
Register the plugin in your panel provider:
use Bambamboole\FilamentMenu\FilamentMenuPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ FilamentMenuPlugin::make() ->locations(['header', 'footer', 'sidebar']) ->linkables([Page::class, Post::class]) ->canAccess(fn () => auth()->user()->isAdmin()) ->cacheFor(3600), ]); }
| Method | Description |
|---|---|
locations(array) |
Named positions where menus can be assigned (e.g. header, footer) |
linkables(array) |
Eloquent models that can be linked as menu items |
canAccess(Closure) |
Controls who can manage menus |
cacheFor(int) |
Cache duration in seconds (auto-invalidated on changes) |
Linkable Models
To let editors link menu items to your Eloquent models, implement the Linkable interface:
use Bambamboole\FilamentMenu\Contracts\Linkable; use Bambamboole\FilamentMenu\Concerns\IsLinkable; use Illuminate\Database\Eloquent\Builder; class Page extends Model implements Linkable { use IsLinkable; public static function getLinkableQuery(): Builder { return static::query()->where('published', true); } public static function getNameColumn(): string { return 'title'; } public function getLink(): string { return route('pages.show', $this->slug); } }
The IsLinkable trait provides sensible defaults — override only what you need.
Rendering Menus
Use the Blade component in your templates:
<x-filament-menu::menu location="header" /> <x-filament-menu::menu slug="main-navigation" />
Or retrieve menus programmatically:
use Bambamboole\FilamentMenu\Models\Menu; $menu = Menu::findByLocation('header'); $tree = $menu->getTree(); // array of nested items
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.