如何在Laravel中检索动态标签数据?

时间:2019-06-17 19:46:03

标签: php laravel tabs

我试图在动态Tabs中显示数据库中的数据,所以我有两个表... Queues和Station。

队列表

enter image description here

站台表

enter image description here

现在,我想在导航选项卡中检索所有电台,并在标签内容

中检索所有带有目标计划的队列。

我已经尝试过以下方法。

<ul  class="nav nav-tabs">
@forelse ($stations as $station)
    <li ><a data-toggle="tab" href="#tab-{{ $station->id }}"  >
        {!! $station->name !!}
    </a></li>
@empty

@endforelse
</ul>

<div style="margin-top: 15%"  class="tab-content">
    @foreach($queues as $station_id => $item)
        <div id="tab-{{ $station->id }}" class="tab-pane fade">
            @foreach($item as $queue)
                <p>{!! $queue->bus_number !!}</p>
            @endforeach
        </div>
    @endforeach
</div>

有人知道另一种方法吗?同样,要在第一个 navtab tab-content 中显示所有电台,我想获取所有目标电台的队列。谢谢大家!

1 个答案:

答案 0 :(得分:1)

更新此部分。 $station->id to $station_id

<div style="margin-top: 15%"  class="tab-content">
    @foreach($queues as $station_id => $item)
        <div id="tab-{{ $station->id }}" class="tab-pane fade">
            @foreach($item as $queue)
                <p>{!! $queue->bus_number !!}</p>
            @endforeach
        </div>
    @endforeach
</div>