【发布时间】:2021-03-23 08:35:00
【问题描述】:
例如第一行的价格是 2,580,000 第二行 950,000 好吧,我想显示所有价格的总和为 3530000,这是我的视图代码:
@forelse ($bookings as $booking)
@php
$check_out= date_create($booking['check_out']);
$check_in = date_create($booking['check_in']);
$calculate = date_diff($check_out, $check_in);
$day = $calculate->format("%a");
$price = $day * $booking->room->price;
@endphp
<tbody>
<th>{{ $loop->iteration + $bookings->firstItem() - 1 . '.' }}</th>
<td><u>{{ $booking->booking_code }}</u></td>
<td>
<span class="badge badge-light">{{ "Rp. " . number_format($price, 0,',','.') }}<span>
</td>
</tbody>
@empty
<tbody>
<tr>
<th colspan="3" style="color: red; text-align: center;">Data Empty!</th>
</tr>
</tbody>
@endforelse
<tfoot>
<tr>
<th>TOTAL</th>
<td></td>
<td>{{ $price + $price }}</td>
</tr>
</tfoot>
【问题讨论】: