-
Notifications
You must be signed in to change notification settings - Fork 64
Building the Sidebar
Patrick Brouwers edited this page Jun 20, 2015
·
2 revisions
Building a new Sidebar is very easy. You create a new class that implements Maatwebsite\Sidebar\Sidebar interface. This will force you to have a build and getMenu method.
getMenu should return the menu instance, which you can inject into the constructor as Maatwebsite\Sidebar\Menu.
Inside build you can add the groups and items.
use Maatwebsite\Sidebar\Menu;
use Maatwebsite\Sidebar\Sidebar;
class MySidebar implements Sidebar
{
/**
* @var Menu
*/
protected $menu;
/**
* @param Menu $menu
*/
public function __construct(Menu $menu)
{
$this->menu = $menu;
}
/**
* Build your sidebar implementation here
*/
public function build()
{
$this->menu->group('settings', function(Group $group) {
$group->item('User Settings');
});
}
/**
* @return Menu
*/
public function getMenu()
{
return $this->menu;
}
}