-
Notifications
You must be signed in to change notification settings - Fork 233
Quick Start
To quickly get started, you can create your menu within a middleware. Below you will find a sample middleware that you may use as a starting point.
Note: Don't forget to register this new middleware from within your
app/Http/Kernel.php
file.
<?php
namespace App\Http\Middleware;
use Closure;
use Menu;
class MenuMiddleware
{
/**
* Run the request filter.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
Menu::make('example', function($menu) {
$menu->add('Home', '/');
$menu->add('About', '/about');
$menu->add('Blog', '/blog');
$menu->add('Contact Me', '/contact-me');
});
return $next($request);
}
}
Note: Simply replace
example
with whatever you wish to call your menu.
From here the package will automatically register your menu as a view composer (prepending your defined menu slug with menu_
) that is accessible from all your views. Rendering your menu is simple from within your blade view files:
{!! $menu_example->asUl() !!}
The above will generate the following HTML:
<ul>
<li><a href="http://yourwebsite.com">Home</a></li>
<li><a href="http://yourwebsite.com/blog">Blog</a></li>
<li><a href="http://yourwebsite.com/about">About</a></li>
<li><a href="http://yourwebsite.com/contact">Contact</a></li>
</ul>
That's it as far as basic usage goes! Pretty simple, no? This is only the tip of the iceberg though, so be sure to go through the documentation here to learn about the more advanced uses (like creating your own Twitter Bootstrap menu)!
- Active Link Detection
- Append and Prepend
- Attributes
- Dividers
- [Meta Data](Meta Data)
- [Sort By](Sort By)