Page event after list

I created a custom field value which i want to access the variable i got from querying the database in the page event. its not showing kindly help

To deal with that, you can use the reference symbol & in PHP. By appending & to a variable, you can make changes to the records.

private function afterList(&$records){
    //enter statement here
    $balance = DB::table('payment')->where('rental_id', '7')->sum('amount');
    $records['bal_1'] = $balance;
}

Note: I just replicated your code and did not check if it was correct, as my solution is to show you how to make changes to the $records variable and let them take effect. Take note of the &$records on the first line.

1 Like