Do you have a RAW query that is working for you? It's easier to start with that and then migrate to Eloquent
Mar 16, 2020
6
Level 2
DB query grouping sum each
i want to achieve
*OrgName #1
- PayPal
- 2020-01-01
[
array_booking
]
- Count Total (LBP)
- Total Sum(LBC) commison
- 2020-01-02
[
array_booking
]
- Count Total (LBP)
- Total Sum(LBC) commison
- 2020-01-04
.
.
- credit Card
- 2020-01-02
[
array_booking
]
- Count Total (SBP)
- Total Sum(SBC) commison
*OrgName #2
bookings table
id |org_id | local_id| check_in| Checkout| commision| Pay| Payment_gateway| create_at| update_at|
my query i just try
$bookedStatus_id=BookStatus::where('name','Booked')->first()->id;
$booking=Booking::with('bookable')->where('book_status_id',$bookedStatus_id)
->where('pay','>',0)
->selectRaw("DATE_FORMAT(Update_date, '%Y %m %e') date")
->get()
->groupBy(['organization_id','payment_gateway','date'])
->toArray();
// db query also try
$booking=DB::table('bookings')->where('book_status_id',$bookedStatus_id)
->where('pay','>',0)
->selectRaw("DATE_FORMAT(check_in, '%Y %m %e') date")
->selectRaw("*,SUM(commison) as sum")
->get()
->groupBy(['organization_id','payment_gateway','date'])
->toArray();
not working for me any help, please
Please or to participate in this conversation.