Support the ongoing development of Laravel.io →
Eloquent Views
Last updated 1 year ago.
0

You can try this code

private static function prepareMenu($tree)
{
    $data = '<ul class="nav navbar-nav">';

    foreach ($tree as $item)
    {
        $data .= '<li><a href="' . $item->url . '">' . $item->title . '</a></li>';

        if (count($item->children) > 0)
        {
            $data .= self::prepareMenu($item->children);
        }
    }

    $data .= '</ul>';

    return $data;
}
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Delavor delavor Joined 15 Jul 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.