Modules or packages can add groups and items to an existing sidebar with a SidebarExtender:
use Wikigods\Sidebar\Group;
use Wikigods\Sidebar\Item;
use Wikigods\Sidebar\Menu;
use Wikigods\Sidebar\SidebarExtender;
class BlogSidebarExtender implements SidebarExtender
{
public function extendWith(Menu $menu)
{
$menu->group('Content', function (Group $group) {
$group->item('Posts', function (Item $item) {
$item->route('admin.posts.index');
});
});
return $menu;
}
}
Merge it from your sidebar's build():
public function build(): void
{
// Your own groups...
foreach ($this->extenders as $extender) {
$this->menu->add(
$extender->extendWith(app(Menu::class))
);
}
}
Menu::add() merges groups by name: items of a group that already exists are added to it.