Create navigation menus for your Laravel application.
felixdorn/laravel-navigation is a Laravel package for create navigation menus for your laravel application..
It currently has 0 GitHub stars and 52 downloads on Packagist (latest version 1.0.0).
Install it with composer require felixdorn/laravel-navigation.
Discover more Laravel packages by felixdorn
or browse all Laravel packages to compare alternatives.
Last updated
Create navigation menus for your Laravel application, works out of the box with Inertia.
Requires PHP 8.0+
You can install the package via composer:
composer require felixdorn/laravel-navigation
use Felix\Navigation\Navigation;
Navigation::register('dashboardSidebar', function (Navigation $navigation) {
});
use Felix\Navigation\Navigation;
Navigation::dashboardSidebar()->toArray();
// alternatively, to get the raw tree underneath:
Navigation::dashboardSidebar()->tree();
use Felix\Navigation\Item;
$navigation->addIf($isAdmin, 'Settings', function (Item $item) {
// ...
});
$navigation->addUnless($isReader, 'Articles', function (Item $item) {
// ...
});
use Felix\Navigation\Item;
use Felix\Navigation\Section;
$navigation->addSection('Name', function (Section $section) {
$section->add('Child', function (Item $item) {
// ...
});
});
use Felix\Navigation\Section;
$navigation->addSectionIf($isAdmin, 'Admin', function (Section $section) {
// ...
});
$navigation->addSectionUnless($isReader, 'Bookmarks', function (Section $section) {
// ...
});
/** @var \Felix\Navigation\Item $item **/
$item->route('articles.index');
$item->route('tenant.show', ['tenant' => 1]);
$item->url('https://github.com/felixdorn')
$item->route('articles.index')
->activeWhenRouteMatches('articles.*') // active for articles.index / articles.edit / articles.anything
$item->meta(['a' => 'b']);
// same as
$item->a('b');
composer test
Navigation for Laravel was created by Félix Dorn under the MIT license.