app/Menu.php
public function bootstrap4(): string
    {
        if (!empty($this->submenus)) {
            $submenus = '';
            foreach ($this->submenus as $submenu) {
                $attrs = '';
                foreach ($submenu->attrs as $key => $value) {
                    $attrs .= ' ' . $key . '="' . e($value) . '"';
                }

                $class = trim('dropdown-item ' . $submenu->class);
                $submenus .= '<a class="' . $class . '" href="' . e($submenu->link) . '"' . $attrs . '>' . $submenu->label . '</a>';
            }

            $class = trim('nav-item dropdown ' . $this->class);

            return
                '<li class="' . $class . '">' .
                '<a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">' .
                $this->label .
                '<span class="caret"></span></a>' .
                '<div class="dropdown-menu" role="menu">' .
                $submenus .
                '</div>' .
                '</li>';
        }

        $attrs = '';
        foreach ($this->attrs as $key => $value) {
            $attrs .= ' ' . $key . '="' . e($value) . '"';
        }

        $class = trim('nav-item ' . $this->class);

        return '<li class="' . $class . '"><a class="nav-link" href="' . e($this->link) . '"' . $attrs . '>' . $this->label . '</a></li>';
    }
public function bootstrap4(): string
    {
        if (!empty($this->submenus)) {
            $submenus = '';
            foreach ($this->submenus as $submenu) {
                $attrs = '';
                foreach ($submenu->attrs as $key => $value) {
                    $attrs .= ' ' . $key . '="' . e($value) . '"';
                }

                $class = trim('dropdown-item ' . $submenu->class);
                $submenus .= '<a class="' . $class . '" href="' . e($submenu->link) . '"' . $attrs . '>' . $submenu->label . '</a>';
            }

            $class = trim('nav-item dropdown ' . $this->class);

            return
                '<li class="' . $class . '">' .
                '<a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">' .
                $this->label .
                '<span class="caret"></span></a>' .
                '<div class="dropdown-menu" role="menu">' .
                $submenus .
                '</div>' .
                '</li>';
        }

        $attrs = '';
        foreach ($this->attrs as $key => $value) {
            $attrs .= ' ' . $key . '="' . e($value) . '"';
        }

        $class = trim('nav-item ' . $this->class);

        return '<li class="' . $class . '"><a class="nav-link" href="' . e($this->link) . '"' . $attrs . '>' . $this->label . '</a></li>';
    }
public function bootstrap4 ( ) : string { if ( ! empty ( $ this -> submenus ) ) { $ submenus = '' ; foreach ( $ this -> submenus as $ submenu ) { $ attrs = '' ; foreach ( $ submenu -> attrs as $ key => $ value ) { $ attrs .= ' ' . $ key . '="' . e ( $ value ) . '"' ; } $ class = trim ( 'dropdown-item ' . $ submenu -> class ) ; $ submenus .= '<a class="' . $ class . '" href="' . e ( $ submenu -> link ) . '"' . $ attrs . '>' . $ submenu -> label . '</a>' ; } $ class = trim ( 'nav-item dropdown ' . $ this -> class ) ; return '<li class="' . $ class . '">' . '<a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">' . $ this -> label . '<span class="caret"></span></a>' . '<div class="dropdown-menu" role="menu">' . $ submenus . '</div>' . '</li>' ; } $ attrs = '' ; foreach ( $ this -> attrs as $ key => $ value ) { $ attrs .= ' ' . $ key . '="' . e ( $ value ) . '"' ; } $ class = trim ( 'nav-item ' . $ this -> class ) ; return '<li class="' . $ class . '"><a class="nav-link" href="' . e ( $ this -> link ) . '"' . $ attrs . '>' . $ this -> label . '</a></li>' ; }
Render this menu using Bootstrap4 markup

@return string
Render this menu using Bootstrap4 markup