ferhnir / laravel-spatie-menu
Laravel Spatie/Menu with Bootstrap for Laravel 9
dev-master
2022-07-21 09:43 UTC
Requires
- php: ^8.0
- laravel/framework: ^v9.0
- spatie/laravel-menu: ^4.1
This package is auto-updated.
Last update: 2025-03-29 00:50:12 UTC
README
This generator provides a support for spatie/laravel-menu with php8
Example:
Links:
#serviceProvider: view()->composer(['your.blade'], function () { app('your-instance-name')->add( LaravelSpatieMenuService::createLink( route: route('buildings.index'), title: 'Buildings', icon: '<i class="menu-icon fas fa-file-alt fa-3x"></i>' ) ); });
Submenus:
view()->composer(['your.blade'], function () { $uniqueSubmenuID = 'ExampleID'; //CREATE SUBMENU MAIN LINK $linkNew = LaravelSpatieMenuService::createLink( route: '#', title: '<span class="menu-label">ExampleLink</span>', icon: '<i class="menu-icon far fa-sitemap fa-3x"></i>', uniqueSubmenuID: $uniqueSubmenuID ); //CREATE SUBMENU OBJECT //Create submenuList for submenuObj $submenuList = LaravelSpatieMenuService::buildSubmenuList( submenuLinksArray: [ [ 'title' => 'Show All', 'icon' => '<i class="far fa-eye"></i>', 'url' => route('example.index'), 'rule' => ['browse-example'] ], [ 'title' => 'Add Company', 'icon' => '<i class="far fa-plus"></i>', 'url' => route('example.create'), 'rule' => ['add-example'] ], [ 'title' => 'Archive', 'icon' => '<i class="far fa-cabinet-filing"></i>', 'url' => route('example.archive'), 'rule' => ['delete-example'] ], ... ] ); //Create submenuObj $submenuObj = LaravelSpatieMenuService::newMenu( uniqueSubmenuID: $uniqueSubmenuID, wrapperTag: 'div', parentTag: false, activeClassOnLink: true ); //Attach submenuObj to menu instance app('your-instance-name')->submenu( $linkNew, $submenuObj->add($submenuList) ); });
Blade 'your.blade'
{!! app('your-instance-name') !!}