maig81 / backpack-menu
Menu system for Backpack 4.1
v1.0.8
2020-07-06 14:02 UTC
Requires
- backpack/crud: ^4.0
- backpack/pagemanager: ^3.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
An multiple menu manager for Laravel Backpack. Created out of the need to make multiple menus and to include multiple models in the menu. It also has a bootstrap menu frontend blade files.
Install
- Run in your terminal:
composer require maig81/backpack-menu - Edit
/config/app.phpand add toprovidersarrayMaig81\BackpackMenu\MenuServiceProvider::class, - Publish the views, config and migrations:
php artisan vendor:publish --provider="Maig81\BackpackMenu\MenuServiceProvider" - Run the migration to have the database table we need:
php artisan migrate - [optional] Add a menu item for it in resources/views/vendor/backpack/base/inc/sidebar.blade.php or menu.blade.php:
php artisan backpack:add-sidebar-content "<li class='nav-item'><a class='nav-link' href='{{ backpack_url('backpackmenu') }}'><i class='nav-icon fa fa-file-o'></i> <span>Menus</span></a></li>"
Usage
- Edit
config/backpackmenu.phpand add models you need to be in the Menu system. The Model should havetitleas it will be in the list. - Edit files in
views/vendor/backpack_menuif you need to alter the views. As the names suggest,menu_template.phpis the outer template for the menu, and themenu_item.blade.phpis a single link that calls itself recursively if there are children. - BackpackMenu model has
getMenuView()that will generate a menu fromviews/vendor/backpack_menuviews.
Example
This is a crude example... You can make a field in your template to get the menu you need.
Add this to your view controller:
$menu = \Maig81\BackpackMenu\App\Models\BackpackMenu::find(1);
return view('your_view', ["menu" => $menu]);
Then, in your view you can add to get the bootstrap menu generated:
$menu->getMenuView();
To Do
- Add
MenuableTrait that you can add to the model. It will addgetLink()andgetTitle()function.