Skip to content

Commit b484288

Browse files
authored
Remove Eloquent\Builder::chunkById() already having the correct id field in laravel (#2569)
1 parent 7d3be9f commit b484288

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

src/Eloquent/Builder.php

-8
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,6 @@ public function decrement($column, $amount = 1, array $extra = [])
153153
return parent::decrement($column, $amount, $extra);
154154
}
155155

156-
/**
157-
* @inheritdoc
158-
*/
159-
public function chunkById($count, callable $callback, $column = '_id', $alias = null)
160-
{
161-
return parent::chunkById($count, $callback, $column, $alias);
162-
}
163-
164156
/**
165157
* @inheritdoc
166158
*/

tests/ModelTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -834,12 +834,12 @@ public function testChunkById(): void
834834
User::create(['name' => 'spork', 'tags' => ['sharp', 'pointy', 'round', 'bowl']]);
835835
User::create(['name' => 'spoon', 'tags' => ['round', 'bowl']]);
836836

837-
$count = 0;
838-
User::chunkById(2, function (EloquentCollection $items) use (&$count) {
839-
$count += count($items);
837+
$names = [];
838+
User::chunkById(2, function (EloquentCollection $items) use (&$names) {
839+
$names = array_merge($names, $items->pluck('name')->all());
840840
});
841841

842-
$this->assertEquals(3, $count);
842+
$this->assertEquals(['fork', 'spork', 'spoon'], $names);
843843
}
844844

845845
public function testTruncateModel()

0 commit comments

Comments
 (0)