Skip to content
Shea Lewis edited this page Mar 7, 2015 · 1 revision

Caffeinated Menus gives you various ways to link to your resources from your menus. Let's go over each method below.


URLs

This is as easy and basic as it goes. You may simply assign a URL to your menu item by passing the URI as the second parameter when adding your menu item:

...

$menu->add('Blog', 'blog');

...

Named Routes

If you make use of the named routes functionality of Laravel, why not do the same for your menu items as well? Simply pass an array referencing the route in the second parameter, like so:

...

$menu->add('Blog', array('route' => 'blog.page'));

...

Controller Actions

You may also link directly to controller actions in a similar manner as named routes:

...

$menu->add('Blog', array('action' => 'BlogController@index'));

...

Named Route and Controller Action Parameters

If you need to pass along additional parameters to either the named routes or controller actions methods, simply utilize an array in place of a string like so:

...

// Named Route
$menu->add('Blog', array('route' => array('blog.page', 'slug' => 'lorem-ipsum-dolor')));

// Controller Action
$menu->add('Blog', array('action' => array('BlogController@index', 'slug' => 'lorem-ipsum-dolor')));

...