Laravel Eloquent: Ordering results By all or get method | get data with orderby or sortby laravel

 

$results = Project::orderBy('name')->get();

 

Ascending Order

 

$results = Project::all()->sortBy("name");

 

Descending Order

 

$results = Project::all()->sortByDesc("name");

Check out the documentation about Collections for more details.

 

https://laravel.com/docs/5.1/collections

 

 

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

 


 

Post a Comment

Previous Post Next Post