Note: I developed this package as a hobby project, but wanted to share it with whoever may need it. I will keep updating this package. If you have any suggestions, feel free to create an issue.
This package offers a powerful menu builder for the Filament admin panel, enabling efficient menu creation and management.
- Integrate models and routes into menu items for dynamic and flexible navigation.
- Render menus with Blade components for consistency and adaptability.
Built for simplicity and performance, this package ensures a seamless solution for managing menus in the Filament admin panel.
Table of Contents:
You can install the package via composer:
composer require biostate/filament-menu-builder
Add the plugin to your AdminPanelServiceProvider.php
:
public function panel(Panel $panel): Panel
{
return $panel
// Your other configurations
->plugins([
\Biostate\FilamentMenuBuilder\FilamentMenuBuilderPlugin::make(), // Add this line
]);
}
You can publish and run the migrations with:
php artisan vendor:publish --tag="filament-menu-builder-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="filament-menu-builder-config"
Optionally, you can publish the views using
php artisan vendor:publish --tag="filament-menu-builder-views"
Menu items are cached in view component by default. If you want to disable caching, you can set the cache
configuration to false
.
You can create relationships between menu items and your models. To enable this feature, you need to add the Menuable
trait to your model and implement the getMenuLinkAttribute
method.
If you want to use the model name as the menu item name, you can use the getMenuNameAttribute
method.
use Biostate\FilamentMenuBuilder\Traits\Menuable;
class Product extends Model
{
use Menuable;
public function getMenuLinkAttribute(): string
{
return route('products.show', $this);
}
public function getMenuNameAttribute(): string
{
return $this->name;
}
}
After this you need to add your model in to the config file. You can add multiple models. eg:
return [
'models' => [
'Product' => \App\Models\Product::class,
],
];
If you add these configurations, you can see the menu items in the menu item forms as a select input.
You can use your routes in the menu items. But if you want to exclude some routes, you can use the exclude_route_names
configuration.
Package excludes the debugbar routes, filament routes, and livewire routes in default.
'exclude_route_names' => [
'/^debugbar\./', // Exclude debugbar routes
'/^filament\./', // Exclude filament routes
'/^livewire\./', // Exclude livewire routes
],
This package provides some blade components to render the menu items. You can use these components in your blade files. You can get this code in the menus table. For example:
<x-filament-menu-builder::menu slug="main-menu" />
This blade component will render the menu items with the main-menu
slug. You can also publish the views and customize the blade components.
Also you can give a custom view to the component. This package supports Bootstrap 5 by default. For example:
<x-filament-menu-builder::menu slug="main-menu" view="filament-menu-builder::components.bootstrap5.menu"/>
- add parameters like mega menu, dropdown, etc.
- add tests
- add tailwind blade component
- add "Do you want to discard the changes?" if you have unsaved changes
- add more actions like: move up, move down, move one level up, move one level down, etc.
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.