$orders = DB::select('select * from orders order by created_at desc'); select first code example
Example 1: laravel get all records order by
$posts = Post::orderBy('created_at', 'desc')->get();
Example 2: laravel get all records order by
$results = Project::orderBy('name')->get();