SQLSTATE[42000]: Syntax error or access violation: 1055 'new.bank_accounts.id' isn't in GROUP BY (Connection: mysql, SQL: select `bank_accounts`.`id`, `bank_accounts`.`holder_name`, `bank_accounts`.`bank_name`, sum(amount) as total from `revenues` left join `bank_accounts` on `revenues`.`account_id` = `bank_accounts`.`id` where `revenues`.`created_by` = 2 and `revenues`.`created_by` = 2 group by `revenues`.`account_id`)
The line of code $reportData['revenueAccounts'] = $revenueAccounts->get();
is fetching revenue account data from the database and storing it in the $reportData
variable. Here's how it works:
$revenueAccounts
is an instance of the Illuminate\Database\Query\Builder class
, which represents a query to the database.
The get()
method on $revenueAccounts executes the query and returns a collection of records from the revenue_accounts table in the database.
The $reportData
variable is an array that stores the data for the report. The line of code $reportData['revenueAccounts'] = $revenueAccounts->get();
assigns the collection of revenue account records to the $reportData['revenueAccounts']
key in the array.
Overall, this line of code fetches the revenue account data from the database and stores it in an array for use in generating a report.
$bankAccount = BankAccount::find($request->account);
$filter['account'] = !empty($bankAccount) ? $bankAccount->holder_name . ' - ' . $bankAccount->bank_name : '';
if ($bankAccount->holder_name == 'Cash')
{
$filter['account'] = 'Cash';
}
if ($request->type == 'revenue' || !isset($request->type))
{
$reportData['revenues'] = $revenues->get();
$revenueAccounts->where('revenues.created_by', '=', \Auth::user()->creatorId());
$reportData['revenueAccounts'] = $revenueAccounts->get();
}
if ($request->type == 'payment')
{
$reportData['payments'] = $payments->get();
$paymentAccounts->where('payments.created_by', '=', \Auth::user()->creatorId());
}
I'M having issue to find all problems