I was grouping the orders data for a graph and used the following eloquent query to achieve that,
Order::selectRaw("CONCAT(monthname(created_at),'-',year(created_at)) as date, count(id) as orders")
->groupBy('date')->get();
I got the expected results on my local machine where dates were in normal order, but when running the same thing on production. I get the following output:
Illuminate\Database\Eloquent\Collection {#4607
all: [
App\Order {#4564
date: "April-2020",
orders: 1,
},
App\Order {#4571
date: "August-2019",
orders: 4,
},
App\Order {#4611
date: "December-2019",
orders: 14,
},
App\Order {#4570
date: "February-2020",
orders: 2,
},
App\Order {#4582
date: "January-2020",
orders: 8,
},
App\Order {#4613
date: "June-2020",
orders: 1,
},
App\Order {#4565
date: "March-2020",
orders: 8,
},
App\Order {#4610
date: "May-2020",
orders: 10,
},
App\Order {#4588
date: "November-2019",
orders: 15,
},
App\Order {#4599
date: "October-2019",
orders: 8,
},
App\Order {#4600
date: "September-2019",
orders: 11,
},
],
}
It seems to be sorted in alphabetical order but I cannot figure out why. Can anyone tell me what could be the issue? And yes on my local I use SQL ver 8, and on prod we use SQL 5, could that be the cause? How would I fix that?
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2z59HZy
via IFTTT
Aucun commentaire:
Enregistrer un commentaire