0
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

Wakil Ahmed
  • 1,053
  • 1
  • 8
  • 16
Imran Niaz
  • 11
  • 4
  • 1
    The columns you retrieve has to belong to columns grouped by. Reference more https://stackoverflow.com/questions/25800411/mysql-isnt-in-group-by – Khang Tran Apr 29 '23 at 03:08
  • 1
    Also this is clearly a problem with group by, feels like something is missing with no part of your question has a group by call. For example we have no idea how $payments is built – mrhn Apr 30 '23 at 20:21

0 Answers0