lavary/laravel-menu

how to make menu with icon

Opened this issue · 1 comments

Hi everybody . I want to build a menu and have an icon. So how should I do it? I don't know how to pass pictures in
I have the code

private function createMenus($menu, $aMenus, $parent_id)
{
foreach ($aMenus as $oMenu) {
if ($oMenu->parent_id == $parent_id) {
$submenu = $menu->add($oMenu->name, "danh-muc-san-pham/" . $oMenu->path);
$this->createMenus($submenu, $aMenus, $oMenu->id);
}
}
}

You should use prepend() to add icon before link or append() to add icon after link.
For example using FontAwaresome Icons:
$menu->add($oMenu->name, "danh-muc-san-pham/" . $oMenu->path)->prepend('<i class="fa-solid fa-briefcase"></i>');

Or another way, you can use only icon without text, replace $oMenu->name with the icons tag:
$menu->add('<i class="fa-solid fa-briefcase"></i>', "danh-muc-san-pham/" . $oMenu->path);
Hope this help.