Краткий запрос Laravel

У меня есть 3 таблицы, называемые cash_manages , outlets и delivery_boys Структура

  //outlets id name 1 utha 2 alabama //delivery_boys id outlet_id name 1 1 John 2 1 Mike 3 2 Alex //cash_manage id source_type source_id destination_id status amount 1 admin 1 2 give 500 2 admin 2 1 give 350 3 deliveryBoy 1 2 receive 300 4 admin 2 2 give 500 5 admin 2 1 give 800 6 user 1 1 give 600 7 user 2 2 give 450 //the logic 1-> if source_type is admin then the source_id is outlet_id and the cash is **GIVEN** to destination_type delivery_boy_id 2-> if source_type is deliveryBoy then the source_id is delivery_boy_id and the cash is **Received** by destination_type outlet_id(admin) 

Я хочу получить результат, как показано ниже, в представлении (деньги с доставкой)

 num outlet delivery_boy cash_taken cash_returned cash_has 1 alabama John 1150 300 1050 2 alabama mike 500 0 500 

Я присоединился ко всем трем столам и смог получить имя Outlet Name и Boy Boy Name . Теперь я застрял в части расчета

 public function index(Request $request) { $outlet_id = $request->outlet_id; $transaction_list = DeliveryCashManage::leftJoin('outlets','outlets.id','delivery_cash_manages.source_id') ->leftJoin('delivery_boys','delivery_boys.id','destination_id') ->where('source_type', 'admin') ->where('source_id', $outlet_id) ->select('delivery_cash_manages.id','outlets.name as outlet','delivery_boys.name as delivery_boy','amount') ->groupBy('delivery_boys.name') ->get(); return view('pages.manager.cash'); } 

я получаю следующую ошибку

 SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'ideal_chicken.delivery_cash_manages.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by (SQL: select `delivery_cash_manages`.`id`, `outlets`.`name` as `outlet`, `delivery_boys`.`name` as `delivery_boy`, `amount` from `delivery_cash_manages` left join `outlets` on `outlets`.`id` = `delivery_cash_manages`.`source_id` left join `delivery_boys` on `delivery_boys`.`id` = `destination_id` where `source_type` = admin and `source_id` = 1 group by `destination_id`) 

Я думаю, что мой запрос или логика ошибочны, вам нужна помощь в исправлении этого

Спасибо