Skip to content

Commit 72275b0

Browse files
committed
Chunk by 1000 by default
1 parent 50a0dd0 commit 72275b0

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/Query.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,11 @@ public function firstOrFail(): Model
196196
/**
197197
* Get all the models from the cache.
198198
*/
199-
public function get(): Collection
199+
public function get(int $chunk = 1000): Collection
200200
{
201201
$models = $this->model->newCollection();
202202

203-
$this->each(
204-
fn (Model $model) => $models->add($model)
205-
);
203+
$this->each(fn (Model $model) => $models->add($model), $chunk);
206204

207205
return $models;
208206
}
@@ -218,7 +216,7 @@ public function exists(): bool
218216
/**
219217
* Execute a callback over each item.
220218
*/
221-
public function each(Closure $callback, int $count = 100): void
219+
public function each(Closure $callback, int $count = 1000): void
222220
{
223221
$this->chunk($count, function (Collection $models) use ($callback) {
224222
foreach ($models as $key => $model) {

0 commit comments

Comments
 (0)