-
Hello, Is any chances to set attribute to Navigation and Section in the same time? $activeMenus = NavigationMenu::with('parents')->get();
$nav = app(Navigation::class);
foreach($activeMenus as $menu) {
$nav->add($menu->title, '#', function(Section $section) use ($menu) {
if ($menu->icon !== null) {
$section->attributes(['icon' => $menu->icon]);
}
if ($menu->parents()->exists()) {
foreach ($menu->parents as $parent) {
$section->add($parent->title, '#')->attributes(['icon' => $parent->icon]);
}
}
}); |
Beta Was this translation helpful? Give feedback.
Answered by
aavram93
Mar 16, 2023
Replies: 1 comment
-
Nevermind... found a solution after investigated Section function add I had that solution for who need in future foreach($activeMenus as $menu) {
$nav->add($menu->title, '#', function(Section $section) use ($menu) {
if ($menu->icon !== null) {
$section->attributes(['icon' => $menu->icon]);
}
if ($menu->parents()->exists()) {
foreach ($menu->parents as $parent) {
$section->add($parent->title, '#', function(Section $test) use ($parent) {
$test->attributes = ['icon' => $parent->icon];
});
}
}
});
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
aavram93
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nevermind... found a solution after investigated Section function add
I had that solution for who need in future