end()
或last()
无效...该怎么办?
@foreach($students as $student)
@foreach($payment_heads as $payment_head)
<td>
@foreach ($student->payment_detail as $payment_detail_one)
@if($payment_detail_one->payment_head_id==$payment_head->id)
<?php
$total=$total+$payment_detail_one->amount;
?>
@if($payment_detail_one === end($$student->payment_detail))
{{$payment_detail_one->amount}}
@endif
@endif
@endforeach
</td>
@endforeach
@endforeach
答案 0 :(得分:0)
请参阅文档https://laravel.com/docs/5.5/blade#the-loop-variable。
end($$student->payment_detail)
用双$$
错了
你可以用这个
@foreach($students as $student)
@foreach($payment_heads as $payment_head)
<td>
@foreach ($student->payment_detail as $payment_detail_one)
@if($payment_detail_one->payment_head_id==$payment_head->id)
<?php
$total = $total + $payment_detail_one->amount;
?>
@if ($loop->last)
{{$payment_detail_one->amount}}
@endif
@endif
@endforeach
</td>
@endforeach
@endforeach