This is some sorting:
- I want to list today's 20 best posts based on "views".
- then, sort it based on "created_at".
How to do it?
Heres my current code (which doesnt work):
$post =
Posts::orderBy('views', 'desc')
->orderBy('created_at', 'desc')
->whereRaw('created_at >= NOW() - INTERVAL 1 DAY')
->limit(20)->get();
via dobieme