2017-03-09 122 views
-2

現在我正在使用Laravel Framework 5.4開發發票應用程序。Laravel 5.4信用卡,借記卡和餘額計算

我在交易表中保存貸方和借方金額。我想顯示信用額度,借方發生額,餘額發生額在刀片模板(同像下面)

enter image description here

+0

你嘗試過這麼遠嗎? – EddyTheDove

+0

Transaction :: Select('*','(credit - debit)as Balance') - > get(); @EddyTheDove – Karthik

+0

請在問題 – Nevermore

回答

0

在你的控制器:

$交易= DB ::表( '交易') - >獲得();

在刀片:

 <?php $tbalance=0; ?> 
     @foreach($transaction as $trans) 
     <tr> 
<td>{{$invaccstatements->ref_no}} </td> 
<td>{{number_format($invaccstatements->credit, 2)}}</td> 
<td>{{number_format($invaccstatements->debit, 2)}}</td> 
<td align="right"><?php $chkbala = $invaccstatements->credit - $invaccstatements->debit; echo $tbalance += $chkbala; ?></td> 
</tr> 
    @endforeach 
+1

<?php $ tbalance = 0中添加代碼片段? ?> @foreach($交易爲$反) ​​{{$反> ref_no}} ​​{{number_format($反式>信貸,2)}} ​​{{number_format($ trans-> debit,2)}} <?php $ chkbala = $ trans-> credit - $ trans-> debit; echo $ tbalance + = $ chkbala; ?> @endforeach – Karthik

相關問題