Laravel错误与正确显示数据

时间:2018-09-03 22:33:19

标签: laravel

当我将多个发票分配给同一用户时,会发生这种情况。 它必须给我另一行:

希瑟姆-> 55

希瑟姆-> 500

enter image description here

查看1:

<tbody>
    @foreach($userinvoice as $uinvoice)
      @if(count($uinvoice->userinvoice))
        <tr>
          <td scope="row">{{$uinvoice->user_name}}</td>
          <td>@include('invoiceamount',['userinvoice'=>$uinvoice->userinvoice])</td>
       </tr>
    @endif
    @endforeach
</tbody>

发票金额视图:

@foreach($userinvoice as $amount)
    <div class="col-md-2"> {{$amount->amount}}</div>
@endforeach

谢谢!

1 个答案:

答案 0 :(得分:1)

您可以尝试这样做:

<tbody>
    @foreach($userinvoice as $uinvoice)
        @if(count($uinvoice->userinvoice))
            @foreach($uinvoice->userinvoice as $amount)
                <tr>
                    <td scope="row">{{$uinvoice->user_name}}</td>
                    <td>{{$amount->amount}}</td>
                </tr>
            @endforeach
        @endif
    @endforeach
</tbody>