I want to make a loan repayment payment plan. I need to put 4 values in a row for each month (loan balance before month, monthly interest repaid, balance repaid and loan at the end of month). I can calculate all these data in controller but I am unable to pass them to view.
Calculation of all elements is ok but I am unable to pass the object to view.
public function show() {
$fLoanAmount = 10000;
$fAPR = 8.3;
$iTerm = 12;
$monthlyInterest = $fAPR/1200;
$payment = round($this->calculateMonthlyPayments($fLoanAmount, $fAPR, $iTerm),2);
for ($n = 0; $n < $iTerm; $n++) {
$loanBalance = $fLoanAmount;
$monthlyInterest = $loanBalance * $fAPR/1200;
$monthlyBalanceRepayment = $payment - $monthlyInterest;
$fLoanAmount = $loanBalance - $monthlyBalanceRepayment;
$paymentPlan = collect([
'loanBalance' => $loanBalance,
'monthlyInterest' => $monthlyInterest,
'monthlyBalanceRepayment' => $monthlyBalanceRepayment,
'loanAmmount' => $fLoanAmount,
]);
}
return view('plan', compact('paymentPlan'));
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire