K
K
Konstantin Timosheno2019-05-27 13:33:11
Laravel
Konstantin Timosheno, 2019-05-27 13:33:11

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

1 answer(s)
A
Alex Wells, 2019-05-27
@Alex_Wells

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 question

Ask a Question

731 491 924 answers to any question