laravel query eloquent order with code example
Example 1: laravel order by
$users = DB::table('users')
-> orderBy('name', 'desc')
-> get();
Example 2: laravel query order by relation
$order = 'desc';
$users = User::join('roles', 'users.role_id', '=', 'roles.id')->orderBy('roles.label', $order)->select('users.*')->paginate(10);