laravel 5.2 - Model::all() order by

后端 未结 3 1831
悲哀的现实
悲哀的现实 2021-02-07 01:46

I get the full collection of a Model with the following:

$posts = Post::all();

However I want this is reverse chronological order.

What is t

3条回答
  •  不要未来只要你来
    2021-02-07 02:13

    As many may be moving to newer versions of Laravel, you can use ::latest() starting in 5.3 - https://laravel.com/docs/5.5/queries#ordering-grouping-limit-and-offset .

提交回复
热议问题