laravel-cursor-chunk maintained by do6po
Description
An easy way to get chunked data from database by cursor functional.
Author
Last update
2025/06/10 12:51
(dev-main)
License
Downloads
869
An easy way to get chunked data from database by cursor functional.
Installation
The package can be installed via composer:
composer require do6po/laravel-cursor-chunk
If you are using Laravel version <= 5.4
or the package discovery
is disabled, add the following providers in config/app.php:
'providers' => [
Do6po\LaravelCursorChunk\Providers\CursorChunkServiceProvider::class,
]
Using
$builder = User::query();
//... some code with builder
foreach ($builder->cursorChunk() as $users) {
//some action with $users
}
use Illuminate\Database\Eloquent\Collection;
$builder = User::query();
//... some code with builder
$action = fn(Collection $users, User $user) => $users->put($user->getKey(), $user);
foreach ($builder->cursorChunk(1000, $action) as $users) {
//some action with $users, chunked by 1000 models and key by id
}
License
The MIT License (MIT). Please see License File for more information.