Skip to content

Instantly share code, notes, and snippets.

@the94air
Created March 30, 2018 09:31
Show Gist options
  • Save the94air/3d97448717964179a3007132c42ebb88 to your computer and use it in GitHub Desktop.
Save the94air/3d97448717964179a3007132c42ebb88 to your computer and use it in GitHub Desktop.
Bootstrap 4 voyager menu template
@php
if (Voyager::translatable($items)) {
$items = $items->load('translations');
}
@endphp
<ul class="navbar-nav ml-auto">
@foreach($items as $item)
@if($item->children->count())
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="{{ url($item->url) }}" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{ $item->title }}
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
@foreach($item->children as $subItem)
@if($subItem->title == 'divider')
<div class="dropdown-divider"></div>
@else
<a class="dropdown-item {!! url($subItem->link()) == url()->current() ? 'active' : '' !!}" target="{{ $subItem->target }}" href="{{ url($subItem->url) }}">{{ $subItem->title }} {!! url($subItem->link()) == url()->current() ? '<span class="sr-only">(current)</span>' : '' !!}</a>
@endif
@endforeach
</div>
</li>
@else
<li class="nav-item {!! url($item->link()) == url()->current() ? 'active' : '' !!}">
<a class="nav-link" target="{{ $item->target }}" href="{{ url($item->url) }}">{{ $item->title }} {!! url($item->link()) == url()->current() ? '<span class="sr-only">(current)</span>' : '' !!}</a>
</li>
@endif
@endforeach
</ul>
@ssAlixss
Copy link

ssAlixss commented May 5, 2019

Very Thank you !!

@daniellealfreitas
Copy link

daniellealfreitas commented Aug 11, 2019

Thank you Very Much. it works;

@the94air
Copy link
Author

Glad I could help 😀

@Andy-susanto
Copy link

thanks bro

@the94air
Copy link
Author

NP! @Andy-susanto 😄

@ghuser655
Copy link

Beautiful! Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment