Update multiple records using Eloquent

Posted 4 years ago by FutureWeb

Hi LarPeeps,

How can I update multiple rows with a single query like:

$update = mysql_query("update item_table set colour = 'black' where item_type_id = 1");

lets say I have 20 rows with the item_type_id of 1 the above would update them all, but when I try:

$update = ItemTable::where('item_type_id', '=', 1);
    $update->colour = 'black';
    $update->save();

laravel spits its dummy out :( any help would be greatly appreciated.

Thanks in advance.

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.