laravel中html表设计中的foreach循环

laravel中html表设计中的foreach循环,laravel,foreach,laravel-5.4,Laravel,Foreach,Laravel 5.4,我有一个数据数组要用html表格显示,但我使用的foreach循环没有给出所需的格式。 下面是数组数据 $data = Array ( [0] => Array ( [id] => 10 [asset_name] => Mini Paver [qty] => 3 [est_start_date] => 02/05/2017

我有一个数据数组要用html表格显示,但我使用的foreach循环没有给出所需的格式。 下面是数组数据

$data =  Array
(
    [0] => Array
        (
            [id] => 10
            [asset_name] => Mini Paver
            [qty] => 3
            [est_start_date] => 02/05/2017
            [days] => 2
            [comments] => Comment 2
            [bundle_name] => 1XRoller 1XPaver
        )

    [1] => Array
        (
            [id] => 11
            [asset_name] => Roller
            [qty] => 2
            [est_start_date] => 03/07/2018
            [days] => 4
            [comments] => Comment 2
            [bundle_name] => 1XRoller 1XPaver
        )
)
我的视图html代码:

@foreach($data as $value) 

<table class="" style="width: 100%;border:1px solid #ccc">
<thead>
 <tr>
    <th colspan="4"> <p><?php echo $value['bundle_name'];?> </p></th>
  </tr>
<tr>
    <th style="text-align: center">id</th>
    <th style="width:5%;text-align: center">Asset Category</th>
    <th style="width:5%;text-align: center">Days</th>
    <th style="width:5%;text-align: center">Qty</th>
</tr>
</thead>
<tbody>

    <tr>
        <th style="text-align: center"><?php echo $value['id'];?> </th>
        <th style="width:5%;text-align: center"><?php echo $value['asset_name'];?></th>
        <th style="width:5%;text-align: center"><?php echo $value['days'];?></th>
        <th style="width:5%;text-align: center"><?php echo $value['qty'];?></th>
    </tr>
                                 
</tbody>
</table>
@endforeach
@foreach($data作为$value)

身份证件 资产类别 天 数量 @endforeach
通过对每个循环使用上面的代码,我得到了下面的html格式,如
bundle name
正在重复

但我需要输出如下:

这意味着我希望bundle名称shluld只出现一次,其余细节应显示为行。 我该怎么做?有什么建议吗?
谢谢。

请尝试下面的代码,
我假设了以下几点,
1.您的bundle\u名称将更改(即您将拥有各种bundle\u名称)。即使您只有一个bundle\u名称,此代码也可以使用。
2.您将按bundle\u名称对结果进行排序。
3.每个bundle\u名称都需要bundle title和table header(同样,即使只有一个bundle\u名称,此代码也可以使用)。
4.bundle\u name的值永远不会为false

@php ($bundle_name = false)
@foreach($data as $value) 
    @if($bundle_name != $value['bundle_name'])
        @if($bundle_name != false)
                </tbody>
            </table>
        @endif
    @php ($bundle_name = $value['bundle_name'])
    <table class="" style="width: 100%;border:1px solid #ccc">
        <thead>
            <tr>
                <th colspan="4"> <p> {{ $bundle_name }} </p></th>
            </tr>
            <tr>
                <th style="text-align: center">id</th>
                <th style="width:5%;text-align: center">Asset Category</th>
                <th style="width:5%;text-align: center">Days</th>
                <th style="width:5%;text-align: center">Qty</th>
            </tr>
        </thead>
        <tbody>
    @endif
            <tr>
                <th style="text-align: center">{{ $value['id'] }} </th>
                <th style="width:5%;text-align: center">{{ $value['asset_name'] }}</th>
                <th style="width:5%;text-align: center">{{ $value['days'] }}</th>
                <th style="width:5%;text-align: center">{{ $value['qty'] }}</th>
            </tr>
@endforeach
</tbody>
</table> 
@php($bundle\u name=false)
@foreach(数据为$value)
@如果($bundle\u name!=$value['bundle\u name']))
@如果($bundle\u name!=false)
@恩迪夫
@php($bundle\u name=$value['bundle\u name']))
{{$bundle\u name}

身份证件 资产类别 天 数量 @恩迪夫 {{$value['id']} {{$value['asset_name']} {{$value['days']} {{$value['qty']} @endforeach
请尝试下面的代码,
我假设了以下几点,
1.您的bundle\u名称将更改(即您将拥有各种bundle\u名称)。即使您只有一个bundle\u名称,此代码也可以使用。
2.您将按bundle\u名称对结果进行排序。
3.每个bundle\u名称都需要bundle title和table header(同样,即使只有一个bundle\u名称,此代码也可以使用)。
4.bundle\u name的值永远不会为false

@php ($bundle_name = false)
@foreach($data as $value) 
    @if($bundle_name != $value['bundle_name'])
        @if($bundle_name != false)
                </tbody>
            </table>
        @endif
    @php ($bundle_name = $value['bundle_name'])
    <table class="" style="width: 100%;border:1px solid #ccc">
        <thead>
            <tr>
                <th colspan="4"> <p> {{ $bundle_name }} </p></th>
            </tr>
            <tr>
                <th style="text-align: center">id</th>
                <th style="width:5%;text-align: center">Asset Category</th>
                <th style="width:5%;text-align: center">Days</th>
                <th style="width:5%;text-align: center">Qty</th>
            </tr>
        </thead>
        <tbody>
    @endif
            <tr>
                <th style="text-align: center">{{ $value['id'] }} </th>
                <th style="width:5%;text-align: center">{{ $value['asset_name'] }}</th>
                <th style="width:5%;text-align: center">{{ $value['days'] }}</th>
                <th style="width:5%;text-align: center">{{ $value['qty'] }}</th>
            </tr>
@endforeach
</tbody>
</table> 
@php($bundle\u name=false)
@foreach(数据为$value)
@如果($bundle\u name!=$value['bundle\u name']))
@如果($bundle\u name!=false)
@恩迪夫
@php($bundle\u name=$value['bundle\u name']))
{{$bundle\u name}

身份证件 资产类别 天 数量 @恩迪夫 {{$value['id']} {{$value['asset_name']} {{$value['days']} {{$value['qty']} @endforeach
所有项目的捆绑包名称是否相同?还是会有所不同?所有项目的捆绑包名称都相同?还是会有所不同?