Skip to content
Advertisement

Laravel group by change keys

Hi I have reservations and their start times. Now I need to raport it.

JavaScript

sumTime is my function to calculate diff between start time and end time. cdate is helper -> carbon::parse($date)..

Result of this is:

JavaScript

Need

But for API it would be better to get like this:

JavaScript

My try

Unfortunately I can’t make it like that. I tried:

JavaScript

But It makes this:

JavaScript

So I can’t do $res[‘2020′][’01’]. How to do It?

Advertisement

Answer

Try this:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement