0

我正在使用 Laravel 5.7。我可以通过使用 while 循环在 Laravel 视图中创建摊销计划php

这是我的代码:

//empty value error handling

// GETTING USER INPUTS AND ASSIGNING THEM TO VARIABLES
$amount = 98000000;
$interest = 8;
$year = 30;
$term = 12;

//creating period
$period = $term * $year;

if ($amount < 0) {
    echo "<p class='error'>Amount Can't be a Negative Value</p>";
}else if ($interest < 0) {
    echo "<p class='error'>Interest Cant't be a Negative Value</p>";
}else if ($year < 0 || $year > 50) {
    echo "<p class='error'>Loan repayment Years 1-50</p>";
}else if ($term<0) {
    echo "<p class='error'>Payment Periods can't be Negative</p>";
}else{
    $i = 0;
    $inter = ($interest / 100) / $term;
    while ($period !=0) {
        // making percentage in $interest
        //Creating the Denominator
        $deno = 1 - 1/pow((1+$inter),$period);
        
        //Payment for a period
        $payment = ($amount * $inter) / $deno;

        //Interest for a Period
        $periodInter = $amount*$inter;

        //Principal for a Period
        $principal = $payment - $periodInter;

        //Getting the Balance 
        $balance = $amount - $principal;

但我不知道如何通过控制器将此循环结果与多行插入 MySQL 数据库?

4

0 回答 0