Laravel: How to get last N entries from DB

前端 未结 7 849
太阳男子
太阳男子 2021-02-01 01:07

I have table of dogs in my DB and I want to retrieve N latest added dogs.

Only way that I found is something like this:

Do         


        
7条回答
  •  别那么骄傲
    2021-02-01 01:13

    Ive come up with a solution that helps me achieve the same result using the array_slice() method. In my code I did array_slice( PickupResults::where('playerID', $this->getPlayerID())->get()->toArray(), -5 ); with -5 I wanted the last 5 results of the query.

提交回复
热议问题