Home

Awesome

Laravel Menu Builder

A menu builder for Laravel 4-5 using Bootstrap's markup.

Build Status Latest Stable Version Total Downloads

Документация на Русском

Note that this package is shipped with no styles nor scripts, you have to download them manually from Twitter Bootstrap's site.

Installation

Install using Composer:

composer require kalnoy/illuminate-menu:~2.0

Add a service provider:

'providers' => [
    'Illuminate\Html\MenuServiceProvider',
],

And a facade:

'aliases' => [
    'Nav' => 'Illuminate\Support\Facades\Nav',
    'Dropdown' => 'Illuminate\Support\Facades\Dropdown',
],

Documentation

Rendering navigation:

{!! Nav::render($items, $attributes) !!}

Where $attributes is optional array of html attributes for ul element.

Rendering a list of menu items without wrapper element:

<ul>{!! Nav::items($items) !!}</ul>

Rendering a single menu item:

{!! Nav::item($label, $url) !!}
{!! Nav::item($label, $options) !!}
{!! Nav::item($options) !!}

See a list of available options below.

Basic example:

Nav::render([
    'Link to url' => 'bar',
    'Link to external url' => 'http://bar',
    [ 'label' => 'Link to url', 'url' => 'bar' ],
    'Link to route' => [ 'route' => [ 'route.name', 'foo' => 'bar' ] ],
]);

Rendering an item with a drop down menu:

{!! Nav::item([
    'label' => 'Settings',
    'icon' => 'wrench',
    'dropdown' => [
        'Foo' => 'bar',
        '-', // divider
        'Logout' => [ 'route' => 'logout_path' ],
    ],
]) !!}

Controlling whether the item is visible:

{!! Nav::item([
    'label' => 'Foo',
    'url' => 'bar',
    'visible' => function () { return Config::get('app.debug'); },
] !!}

Item options

You can specify an array of following options:

Changing the state of the item:

Presentation options:

Nav-specific options

Customization

Though this menu builder intended to be used together with bootstrap markup, you can customize it however you like by extending Illuminate\Html\MenuBuilder class and overriding base methods.