Laravel Eloquent: Ordering results of all()

后端 未结 10 1544
野的像风
野的像风 2020-12-07 10:09

I\'m stuck on a simple task. I just need to order results coming from this call

$results = Project::all();

Where Project is

10条回答
  •  余生分开走
    2020-12-07 10:57

    In addition, just to buttress the former answers, it could be sorted as well either in descending desc or ascending asc orders by adding either as the second parameter.

    $results = Project::orderBy('created_at', 'desc')->get();
    

提交回复
热议问题