lunestudio / filament-navigation-manager
A navigation manager for Filament projects.
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:laravel-package
Requires
- php: ^8.0
- guava/filament-icon-picker: ^2.2
- spatie/eloquent-sortable: ^4.4
- spatie/laravel-package-tools: ^1.18
Requires (Dev)
- filament/filament: ^3.2
- larastan/larastan: ^3.0
- laravel/pint: ^1.19
- orchestra/canvas: ^9.2
- orchestra/testbench: ^9.9
- phpunit/phpunit: ^11.5
README
A menu management plugin for Filament.
Installation
You can install the package via composer:
composer require lunestudio/filament-navigation-manager
Then run the installation command to publish migrations and assets:
php artisan filament-navigation-manager:install
After that, you will need to add a plugin to your AdminPanelProvider
public function panel(Panel $panel): Panel { return $panel ->default() ->id('admin') ->path('admin') ->plugins([ // ...$plugins, FilamentNavigationManagerPlugin::make(), ]); }
To publish the config file, run:
php artisan vendor:publish --tag="filament-navigation-manager-config"
Here is the content of the published config file:
return [ 'model' => \Lunestudio\FilamentNavigationManager\Models\Menu::class, 'resources' => [ 'label' => 'Menu', 'plural_label' => 'Menus', 'navigation_group' => null, 'navigation_label' => 'Menus', 'navigation_icon' => 'heroicon-o-list-bullet', 'navigation_sort' => null, 'navigation_count_badge' => false, 'resource' => \Lunestudio\FilamentNavigationManager\Filament\Resources\MenuResource::class, ], 'linkable' => [ [ 'model' => \App\Models\User::class, 'label' => __('Users'), 'model_prop_to_pluck' => 'name', 'item_prop_to_text' => 'name', 'route_name' => 'user', 'model_prop_to_route' => 'email', ], // [ // 'model' => $full_class_name, // 'label' => $text_label_to_linkable_type_select, // 'model_prop_to_pluck' => $fillable_name, // 'item_prop_to_text' => $fillable_name, // 'route_name' => $route_name, // 'model_prop_to_route' => $fillable_name_and_route_attr, // ], ], ];
Linkable items must consider the properties of the models and the attributes of the routes.
The properties model_prop_to_pluck
, item_prop_to_text
, and model_prop_to_route
must be fillable.
At the same time, the model_prop_to_route
property must be defined with the same name as the model property, and the route must be named.
An example for the linkable User is:
Route::get('/users/{email}', function () { return view('dashboard'); })->name('user');
And in the model:
class User extends Authenticatable { protected $fillable = [ 'name', 'email', ]; }
Menu Resource
This is the index page for creating menus.
You can define the following properties: Name
, Location
, Append profile item
and Keep on mobile
.
You can also add menu items and define: Parent Item
, Linkable Type
, Linkable Id
, Custom Link
, Ícon
, Name
, Extra Classes
and Link Target
.
Afterward, you can reorder items by dragging and dropping them.
Menu Blade Component
To make it as easy as possible to output your menu, Lunestudio provides an
<x-navigation-manager::menu>
blade component.
The default location is main
, but you can change it to any registered menu location.
<x-navigation-manager::menu /> <x-navigation-manager::menu menu-location="footer" />
This is the default view
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.