Add an option second closure
argument to the chunk
Collection function
#38735
Unanswered
troy-whitespark
asked this question in
Ideas
Replies: 1 comment
-
Made a PR here #39065 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I propose that the
->chunk($int)
function on collections be updated to->chunk($int, $func = null)
to match the chunk function on the Eloquent query builder. If the$func
closure is passed, then the chunk function will pass it to->each()
on each of the chunks.One common pattern I have when I'm writing a command that can process several hundred thousand database records is to allow an optional
random-slice
argument, it allows me to take a subset of the records so I can test that everything works before executing the big command. Because the command will process so many records, I generally like to chunk it.Having this matching function signature will allow me to use either a query builder instance or a collection of actual items I pulled for testing purposes.
Beta Was this translation helpful? Give feedback.
All reactions