laravel sort by eloquent code example
Example 1: laravel order by
$users = DB::table('users')
-> orderBy('name', 'desc')
-> get();
Example 2: eloquent model sort by ascending order
$posts = Post::orderBy('id', 'DESC')->get();
$users = DB::table('users')
-> orderBy('name', 'desc')
-> get();
$posts = Post::orderBy('id', 'DESC')->get();