Skip to content

Commit b61be9b

Browse files
authored
Merge pull request #5931 from reinink/7.x
[7.x] Add query builder reorder() documentation
2 parents b7995cb + 868d6f5 commit b61be9b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

queries.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,20 @@ The `inRandomOrder` method may be used to sort the query results randomly. For e
590590
->inRandomOrder()
591591
->first();
592592

593+
#### reorder
594+
595+
The `reorder` method allows you to remove all the existing orders and optionally apply a new order. For example, you can remove all the existing orders:
596+
597+
$query = DB::table('users')->orderBy('name');
598+
599+
$unorderedUsers = $query->reorder()->get();
600+
601+
To remove all existing orders and apply a new order, provide the column and direction as arguments to the method:
602+
603+
$query = DB::table('users')->orderBy('name');
604+
605+
$usersOrderedByEmail = $query->reorder('email', 'desc')->get();
606+
593607
#### groupBy / having
594608

595609
The `groupBy` and `having` methods may be used to group the query results. The `having` method's signature is similar to that of the `where` method:

0 commit comments

Comments
 (0)