Skip to content

Commit

Permalink
Chunk by 1000 by default
Browse files Browse the repository at this point in the history
  • Loading branch information
stevebauman committed Nov 22, 2024
1 parent 50a0dd0 commit 72275b0
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,11 @@ public function firstOrFail(): Model
/**
* Get all the models from the cache.
*/
public function get(): Collection
public function get(int $chunk = 1000): Collection
{
$models = $this->model->newCollection();

$this->each(
fn (Model $model) => $models->add($model)
);
$this->each(fn (Model $model) => $models->add($model), $chunk);

return $models;
}
Expand All @@ -218,7 +216,7 @@ public function exists(): bool
/**
* Execute a callback over each item.
*/
public function each(Closure $callback, int $count = 100): void
public function each(Closure $callback, int $count = 1000): void
{
$this->chunk($count, function (Collection $models) use ($callback) {
foreach ($models as $key => $model) {
Expand Down

0 comments on commit 72275b0

Please sign in to comment.