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;">{{$payment->id}}</td>
<td>@if($payment->payer_id){{$payment->payer->customer_name}}@endif</td>
<td style="width:120px;">{{$payment->payment_amount}}</td><td>{{$payment->payment_distributions->count()}}
@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.