vendredi 14 mai 2021

Laravel PHP: Get values out of Recursion Function

I have a invoice_schedule_table which is structured like:
id, previous_invoice_schedule_id, due_date
7559, , 01-06-2021
7772, 7559, 15-06-2021
7773, 7772, 20-06-2021

I am trying to create a looping/recursive function which will ultimately give me back the last due_date (20-06-2021) if I am opening up any invoice schedule(ID: 7559, 7772) from the UI.

function latestRescheduledInvoiceSchedule($invoiceScheduleId) {

    $rescheduledPaymentSchedule = InvoiceSchedule::where('previous_invoice_schedule_id', $invoiceScheduleId)->first();

    if(isset($rescheduledPaymentSchedule)) {
        latestRescheduledInvoiceSchedule($rescheduledPaymentSchedule->id);
    }
}

But I am unable to figure out how to get the value once it reaches the last record.

Any help regarding this?


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire