Answer the question
In order to leave comments, you need to log in
How to sort correctly in laravel 5.7?
Hi all. I'm sorting posts on the 5.7 stall
The whole point is that sortBy does not normally sort by date. The scatter happens. Partly forms, partly not.
In migration, this field is datetime, but when I save it, it is saved in this format$posts->where('category_id', 1)->sortBy('date')
2018-05-27 00:00:00
Answer the question
In order to leave comments, you need to log in
sortBy? Is this a collection method?)
orderBy should be in the builder, and not on the collection.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question