PHP Laravel-具有子下拉菜单的Bootstrap 4 Nav下拉菜单

时间:2019-04-03 16:03:48

标签: php laravel bootstrap-4

我正在使用Laravel 5.x在一个崭新的网站上工作。作为改头换面的一部分,我正在使用引导程序4.2,但是在将数据动态添加到下拉菜单中以及传递错误的ID时遇到问题。

没有引导程序的旧代码是

<div class="dropdown">
      <span class="dropdown-label" tabindex="0">
      <span>Seasons</span>
          @include('includes.caret')
       </span>
       <nav class="overlay">
        @foreach ($seasons['data'] as $s)
                   <div class="dropdown">
                   <span class="dropdown-label" tabindex="0">
                   <span>{{ $s['name'] }}</span>
                      @include('includes.caret')
                   </span>
                   <nav class="overlay">
                   @foreach ($s['competitions']['data'] as $c)
                        @if ($c['organisation_id'] == $organisation['id'])
                            {{ HTML::link('/bisha/c-' . $c['id'], $c['name']) }}
                        @endif
                   @endforeach
                </nav>
            </div>
        @endforeach
    </nav>
</div>

在皮肤上使用bootstrap 4

<li class="dropdown nav-item"><a class="dropdown-toggle nav-link" data-toggle="dropdown" aria-expanded="false" href="#">Seasons</a>
<div class="dropdown-menu" role="menu">
@foreach ($seasons['data'] as $s)
    <a class="dropdown-item nav-item dropdown-toggle" role="presentation" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">{{ $s['name'] }}</a>
    <ul class="dropdown-menu" aria-labelledby="navbarDropdown">

       <li class="dropdown">
            @foreach ($s['competitions']['data'] as $c)
            @if ($c['organisation_id'] == $organisation['id'])
             {{ HTML::link('/bisha/c-' . $c['id'], $c['id']) }} {{-- this is always returning 157 and only returning one result where there should be multiple results in each --}}
            @endif 

            @endforeach
       </li>
   </ul>
@endforeach
</div>

如果有人可以帮助我解决我的问题,我将不胜感激。我大约有10年没有使用PHP的经验,这也是我第一次使用Laravel。

我一直尝试遵循的示例在此处

https://bootsnipp.com/snippets/35p8X,目前我还没有添加JavaScript,因为我没有得到正确数量的结果。

0 个答案:

没有答案