dowilcox / knp-menu-laravel
Laravel package to create navigation menus, based on KnpLabs/KnpMenu.
Installs: 3 398
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 2
Open Issues: 0
Requires
- illuminate/support: ~5.0 || ~5.1
- knplabs/knp-menu: ~2.0
Requires (Dev)
- phpunit/phpunit: ~4.5
This package is not auto-updated.
Last update: 2024-11-09 17:35:18 UTC
README
Laravel 5 package to create navigation menus, based on KnpLabs/KnpMenu.
Installation
Add to your composer.json file
"dowilcox/knp-menu-laravel": "1.0.*"
Register the package
In config/app.php add the service provider and alias.
Dowilcox\KnpMenu\MenuServiceProvider::class,
'Menu' => Dowilcox\KnpMenu\Facades\Menu::class,
Publish config
php artisan vendor:publish
Example
$menu = Menu::create('main-menu', ['childrenAttributes' => ['class' => 'nav']]); $menu->addChild('Home', ['uri' => url('/')]); $menu->addChild('Users', ['uri' => route('admin.users.index')]); $menu->addChild('Roles', ['uri' => route('admin.roles.index')]); $menu->addChild('Menu', ['uri' => url('menu')]); echo Menu::render($menu);
Will output:
<ul class="nav"> <li class="first"> <a href="http://localhost:8000">Home</a> </li> <li> <a href="http://localhost:8000/admin/users">Users</a> </li> <li> <a href="http://localhost:8000/admin/roles">Roles</a> </li> <li class="current active last"> <a href="http://localhost:8000/menu">Menu</a> </li> </ul>