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 1 commit
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
Next Next commit
Add query builder reorder() documentation
  • Loading branch information
reinink committed Apr 1, 2020
commit f55d2a8e350c6509318c9ec9b3e0ae71fb01e71b
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