Skip to content

[8.x] Add documentation for lazyByIdDesc method #7488

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

Merged
merged 4 commits into from
Dec 6, 2021
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion eloquent.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,8 @@ Flight::where('departed', true)
->each->update(['departed' => false]);
```

You may filter the results based on the descending order of the `id` using the `lazyByIdDesc` method.

<a name="cursors"></a>
### Cursors

Expand Down Expand Up @@ -948,7 +950,7 @@ If you wish to exclude certain models from being pruned while pruning all other

$schedule->command('model:prune', [
'--except' => [Address::class, Flight::class],
])->daily()
])->daily();

You may test your `prunable` query by executing the `model:prune` command with the `--pretend` option. When pretending, the `model:prune` command will simply report how many records would be pruned if the command were to actually run:

Expand Down
2 changes: 1 addition & 1 deletion queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ DB::table('users')->orderBy('id')->lazy()->each(function ($user) {
});
```

Once again, if you plan to update the retrieved records while iterating over them, it is best to use the `lazyById` method instead. This method will automatically paginate the results based on the record's primary key:
Once again, if you plan to update the retrieved records while iterating over them, it is best to use the `lazyById` or `lazyByIdDesc` methods instead. These methods will automatically paginate the results based on the record's primary key:

```php
DB::table('users')->where('active', false)
Expand Down