Skip to content

Extending the Sidebar

Patrick Brouwers edited this page Jun 21, 2015 · 2 revisions

If you are working in a Module based directory structure, you might want to set the specific sidebar items in their own folder. This is possibly by using sidebar extenders:

use Maatwebsite\Sidebar\SidebarExtender;

class YourModuleSidebarExtender implements SidebarExtender 
{
    public function extendWith(Menu $menu)
    {
        $menu->group('Your Module');

        return $menu;
    }
}

You can easily register these extenders in your custom Sidebar class:

class YourSidebar implements Sidebar
{
    public function build()
    {
        $extender = new YourModuleSidebarExtender; 

        $this->menu->add(
            $extender->extendWith($this->menu)
        );
    }
}