I want to do subtraction operations inside the Laravel blade view. I knew it was the wrong approach I need to do it from the controller, but can someone give me the proper solution to do it directly inside the blade view?
Note: I am a newbie to programming.
Here is my code
@if(!empty($receipt_details->total_due))
<tr>
<th>
Customer Old Due
</th>
<td>
{{$receipt_details->all_due}} - {{$receipt_details->total_due}}
</td>
</tr>
@endif
您可以像这样在同一个{{}}
添加它
{{$receipt_details->all_due - $receipt_details->total_due}}
Optimal way for doing this will be to this in the DB query itself.
Here is the raw query sample
SELECT all_due, total_due, (all_due-total_due) as old_due FROM reciept_details;
Database engines are usually optimized to do these kinds of operations, and this will also save some resources on your application server.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.