где я ошибся b / c я использую, когда дело обстоит так?
CASE WHEN payment_gateway = 'paypal' and 'LocalBook' THEN
или b / c после того, как вместо имени столбца вычесть два значения столбца ??
DB::raw("SUM(CASE WHEN bookings.payed_to_owner IS NULL AND bookings.payment_gateway = 'LocalBook' and 'paypal' THEN (select SUM(pay) AS total_payed)- (select SUM(commision_i_get) AS total_commission) ELSE 0 END) AS local_international_deposite"),
полный код запроса
$bookedStatus_id=BookStatus::where('name','Booked')->first()->id;
$bookingsListMonth = DB::table('bookings')
->join('organizations','organizations.id','=','bookings.organization_id')
->join('users','users.id','=','organizations.user_id')
->join('cities','cities.id','=','organizations.city_id')
->select([
'bookings.organization_id',
'users.company_account',
'users.name',
'users.phone',
'cities.name',
DB::raw("DATE_FORMAT(bookings.created_at, '%m-%Y') Month"),
DB::raw('month(bookings.created_at) as month'),
DB::raw("COUNT(CASE WHEN bookings.pay > '0' THEN 1 ELSE 0 END) AS all_booking_per_month"),
DB::raw("SUM(CASE WHEN bookings.payed_to_owner IS NULL AND bookings.payment_gateway = 'LocalBook' and 'paypal' THEN (select SUM(pay) AS total_payed)- (select SUM(commision_i_get) AS total_commission) ELSE 0 END) AS local_international_deposite"),
DB::raw("SUM(CASE WHEN payment_gateway = 'selfBook' THEN commision_i_get ELSE 0 END) AS my_commission"),
DB::raw("SUM(CASE WHEN payment_gateway = 'paypal' and 'LocalBook' THEN commision_i_get ELSE 0 END) AS my_commission_i_collected"),
DB::raw('SUM(commision_i_get) AS total_comission_per_month'),
])
->where('book_status_id',$bookedStatus_id)
->where('pay', '>', 0)
->groupBy(['bookings.organization_id','users.name','users.company_account','users.phone','cities.name','Month','month'])
->get()
->toArray();
dd($bookingsListMonth);
любая помощь спасибо !!