I am trying to speed up my application and have a question about performing actions on a single Eloquent query.
I need to draw a table containing different totals.
$records = $this->finance
->where('company_id','=',$this->company_id)
->where(DB::raw('MONTH(date)'), '=', $month['month'])
->where(DB::raw('YEAR(date)'), '=', $year)
->where('financeaccounts_id', '=', $account);
$income = $records->where('type','=','Income')->sum('amount');
$expense = $records->where('type','=','Expense')->sum('amount');
$correction = $records->where('type','=','Correction')->sum('amount');
'Income' is being calculated correctly, however the subsequent 'sums' aren't. I am guessing that the query is being modified with each assignment. I'd appreciate your help. Thanks