I want to get rows from the end of the table, but in asc
order.
We have this data: Result: 1, 2, 3, 4, 5, ..., 99. Message::select()->where('thread_id', $id)->orderBy('updated_at', 'asc')->get();
If we change orderBy
to desc
and use it with take(5)
, then we have: Result: 99, 98, 97, 96, 95. Message::select()->where('thread_id', $id)->skip(0)->take(5)->orderBy('updated_at', 'desc')->get();
How can I get Result: 95, 96, 97, 98, 99?
p.s. of course I can do it with skip(95)->take(5)->orderBy('updated_at', 'asc')
, but how to do it dynamically.
via Alex