Skip to content

Commit

Permalink
Add query builder reorder() documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
reinink committed Apr 1, 2020
1 parent b7995cb commit f55d2a8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,20 @@ The `inRandomOrder` method may be used to sort the query results randomly. For e
->inRandomOrder()
->first();

#### reorder

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:

$query = DB::table('users')->orderBy('name');

$unorderedUsers = $query->reorder()->get();

To apply a new order at the same time, include the column you wish to sort by as the first argument and the direction as the second argument:

$query = DB::table('users')->orderBy('name');

$usersOrderedByEmail = $query->reorder('email', 'desc')->get();

#### groupBy / having

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:
Expand Down

0 comments on commit f55d2a8

Please sign in to comment.