Easy way to manage menus in laravel 5.1

Are you the type of person that writes menus by hand in view files or do you find yourself looking for the best place to store links to pages on your website? then Menu is for you!

Quick overview example

$menu = Menu::handler('mailbox'); 

// items
    ->add('contacts', 'Contacts')
    ->add('inbox', 'Inbox')
    ->raw(null, null, ['class' => 'divider'])
    ->add('folders', 'Folders', Menu::items() 
        ->add('urgent', 'Urgent') // with prefix: /folders/urgent
        ->add('sent', 'Sent')
        ->add('deleted', 'Deleted')

// styling
    ->addClass('nav navbar-nav')
    ->map(function($item) {
        if ( $item->isActive() )  {

{!! $menu !!} will output:

<ul class="nav navbar-nav">
  <li class="active"> <!-- current element in laravel, detected by library -->
    <a href="http://myapp.com/contacts">Contacts</a>
    <a href="http://myapp.com/inbox">Inbox</a>
  <li class="divider"></li>
    <a href="http://myapp.com/folders">Folders</a>
        <a href="http://myapp.com/folders/urgent">Urgent</a>
        <a href="http://myapp.com/folders/sent">Sent</a>
        <a href="http://myapp.com/folders/deleted">Deleted</a>

About the author

Deven Rathore

I'm Deven Rathore, a multidisciplinary & self-taught designer with 3 years of experience. I'm passionate about technology, music, coffee, traveling and everything visually stimulating. Constantly learning and experiencing new things.

Pin It on Pinterest