Yassine Jennane
Yassine Jennane

Reputation: 79

Laravel Error with displaying data correctly

this happens when I attribute multiple invoices to the same user. It must give me another row:

Hicham -> 55

Hicham ->500

enter image description here

View 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>

Invoiceamount View :

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

Thank you !

Upvotes: 0

Views: 24

Answers (1)

GMachado
GMachado

Reputation: 801

You could try and do like that:

<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>

Upvotes: 1

Related Questions