Laravel - Query Builder - Removing Existing Orderings
The reorder
method removes all of the "order by" clauses that have previously been applied to the query:
$query = DB::table('users')->orderBy('name');
$unorderedUsers = $query->reorder()->get();
You may pass a column and direction when calling the reorder
method in order to remove all existing "order by" clauses and apply an entirely new order to the query:
$query = DB::table('users')->orderBy('name');
$usersOrderedByEmail = $query->reorder('email', 'desc')->get();