8 months ago

How to get the latest item by id.

Posted 8 months ago by strangequirks

I am trying to do get all the latest items and sort by id descending (i.e. get all items that were just added with a limit and offset).

This is my code-

$products = Product::all()

However it seems when I have more that that limit, then I dont have the right order. It gets me say 10 products but not sorted corrected. Any idea how to do this?

Please sign in or create an account to participate in this conversation.