I would like to have the sum of the 4th column of a table, and I dry miserably.
My controller:
public function ticket()
{
$cmdbars = DB::table('bars')
->orderBy('updated_at', 'asc')
->get();
return view('bar_iframe', compact('cmdbars'));
}
My view :
<table>
@foreach($cmdbars as $cmdbar)
<tr>
<td>
{{ $cmdbar->la_qtt }}
</td>
<td>
{{ $cmdbar->la_denom }}
</td>
<td class="txtr">
{{ number_format($cmdbar->le_tarif_bar/100, 2, '.', ' ') }}
</td>
<td class="txtr">
@php
$sum_produit = $cmdbar->le_tarif_bar * $cmdbar->la_qtt;
@endphp
{{ number_format($sum_produit/100, 2, '.', ' ') }}
</td>
</tr>
@endforeach
<tr>
<td colspan="4">
<div class="total_cmd">
{{-- HERE, I would like the sum of the 4th column --}} €
</div>
</td>
</tr>
I'm looking for a day and I'm blocking on this problem, Thanks for your help