Using Eloquent, how can I terminate chunking based on a condition within the chunk function's closure? I've tried returning, but that seems to terminate only the current chunk and not all chunking. At this point, I want to stop retrieving records from the database.
$query->chunk(self::CHUNK_SIZE, function ($objects) {
if (someCondition) {
// terminate chunking here
return;
}
});