I have a blade with a rather long (at least for me) set of conditional statements. At the moment it looks like this:
<table>
<tbody>
@foreach($payments as $payment)
<tr>
<td style="width:120px;"></td>
<td>@if($payment->payer_id)@endif</td>
<td style="width:120px;"></td><td>
@if($payment->payment_distributions->count()>0)
@foreach($payment->payment_distributions as $pd)
@if($pd->amount > 0)
@if($pd->shipment->balance)
@if($pd->amount < $pd->shipment->balance)
<small class="label pull-right bg-red">1</small>
@else
@endif
@else
@endif
@else
@endif
@endforeach
@else
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
In the middle of all that is where it is important, as you can see, it returns a red 1 if the innermost statement returns true. This is of course solely for my benefit, but what I would like is to have it count how many times within overall if statement it returns true, so rather than returning 7 red 1s, I'd like it to return just a red 7.
I've been looking everywhere but I can't seem to find what I'm looking for. It's always possible I just am searching with the incorrect terms but I really would appreciate any help while I continue to search.
Best - Matt
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2CeT6C5
via IFTTT
Aucun commentaire:
Enregistrer un commentaire