Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] Add query builder reorder() documentation #5931

Merged
merged 2 commits into from
Apr 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 remove all existing orders and apply a new order, provide the column and direction as arguments to the method:

$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