簡體   English   中英

PHP或Blade - 根據數據的數量組織的列

[英]PHP or Blade - Organized Columns depending on the number of data

我被阻止整理菜單的子菜單。 正如您所看到的,它被分解為幾個塊(我使用paint將塊分隔為黑色)。

在此輸入圖像描述

目前我的代碼是:

<li class="dropdown yamm-fw">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-delay="200">{{ $category->nom }} <b class="caret"></b></a>
        <ul class="dropdown-menu">
            <li>
                <div class="yamm-content">
                    <div class="row">
                        <div class="col-sm-3">
                            <h5>test</h5>
                            <ul>     
                                <?php $count=0 ?>
                                @foreach ($types->whereIn('id', $category->produit->unique('type_id')->pluck('type_id')) as $type)
                                    @if ($count <= 6)
                                        <li><a href="#">{{$type->nom}}</a></li>
                                        <?php $count++ ?>
                                    @endif
                                @endforeach 
                            </ul>
                        </div>
                        <div class="col-sm-3">
                            <h5>teste 2</h5>
                            <ul>
                                <li><a href="category.html">Trainers</a></li>
                                <li><a href="category.html">Sandals</a></li>
                                <li><a href="category.html">Hiking shoes</a></li>
                                <li><a href="category.html">Casual</a></li>
                            </ul>
                        </div>

在實際div col-sm-3中的7個項目后,我不知道如何做到這一點,創建另一個div來繼續foreach等等。

你可以使用$loop變量

@if ($loop->iteration === 7)
    // Create another div here
@endif

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM