Skip to content

Attach attribute for childrens #24

Closed Answered by aavram93
aavram93 asked this question in Q&A
Discussion options

You must be logged in to vote

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];
                        });
                    }…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by aavram93
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant