I would like to improve the following code to insert 1000 records at once rather than within the chunked loop.
public function fire()
{
$self = $this;
$time = date('Y-m-d H:i:s');
$this->info('Starting chunk: '.$time);
Item::chunk(1000, function($items) use ($self)
{
foreach ($items as $item)
{
$sizeInBytes = $self->getCurlHeaders($item->bigimg);
$item->imgsize = (string) $sizeInBytes;
$item->save();
}
$time = date('Y-m-d H:i:s');
$self->info('Ending chunk: '.$time);
exit;
});
}
How can I do that with the Eloquent ORM and Laravel? The code is running as an artisan task. The target table has ~1000000 rows.