6

Hi I was wondering how I can do a bulk update in laravel 4 rather then looping and updating in chunks?

I know bulk insert is like this:

$invoiceitem->insert($items_array);
user1424508
  • 3,231
  • 13
  • 40
  • 66

2 Answers2

13

You could use eloquent.

Model::whereIn($items_array)->update(array('Foo' => 'Bar'));
Wistar
  • 3,770
  • 4
  • 45
  • 70
0

Bulk update is easy by installing a simple package

https://github.com/rajmn/batchquery-package

Update multiple column in a table by a specific conditions also insert multiple row at a time

Raj Mn
  • 1
  • Given this question was asked nearly 7 years ago I double it needs an answer now :) – Holo Mar 06 '21 at 23:54