Sunday, May 21, 2017

Update multirecords in Laravel 5.2

I have created following piece of code in order to update multiple records using Laravel.

$all_id =[1,2,3,4,5];
$desc = ['one','two','three','four','five'];
Descriptions::whereIn('id', $all_id)->update(['description' => $a]);

The script above worsk only if if I put a sinlge value for description

   Descriptions::whereIn('id', $all_id)->update(['description' =>   'description]);

I need to pass the array $des in order to update all descriptions related to their ids.



via Robert

Advertisement