I integrated the jeroennoten / Laravel-AdminLTE into a project Laravel 5.7 , however, I'm having trouble generating a multilevel menu.
According to the reference contained in the project repository jeroennoten / Laravel-AdminLTE , this would be the code for generating a menu at runtime;
public function boot(Dispatcher $events)
{
$events->listen(BuildingMenu::class, function (BuildingMenu $event) {
$event->menu->add(trans('menu.pages'));
$items = Page::all()->map(function (Page $page) {
return [
'text' => $page['title'],
'url' => route('admin.pages.edit', $page)
];
});
$event->menu->add(...$items);
});
}
The above template was returning error, so I had to make some changes:
public function boot(Dispatcher $events)
{
$events->listen(BuildingMenu::class, function (BuildingMenu $event) {
$event->menu->add(trans('menu.pages'));
$items = Page::all()->map(function (Page $page) use ($event){
$event->menu->add([
'text' => $page['name'],
'url' => $page['url']
]);;
});
});
}
Now it's working, but I still can not solve the multilevel menu issue. Another problem factor is that the amount of levels is undefined. How can I create multiple levels considering the above project approach? Considering that in my database I have basically the columns: id, title, url and parent_id.