Similar to each()
method, but easier to use. Automatically splits the result into parts (chunks).
1return User::orderBy('name')->chunkMap(fn ($user) => [2 'id' => $user->id,3 'name' => $user->name,4]), 25);
Tip given by @PascalBaljet
Similar to each()
method, but easier to use. Automatically splits the result into parts (chunks).
1return User::orderBy('name')->chunkMap(fn ($user) => [2 'id' => $user->id,3 'name' => $user->name,4]), 25);
Tip given by @PascalBaljet