Update multiple records using Eloquent

How to set every row to the same value with Laravel's Eloquent/Fluent?

Example:

id    |   data         |  confirmed 
1     | someData |      0 
2     | someData |      1 
3     | someData |      0

There is a way to do this with fluent:

$affected = DB::table('table')->update(array('confirmed' => 1));

or even better

$affected = DB::table('table')->where('confirmed', '=', 0)->update(array('confirmed' => 1));

Update multiple records using Eloquent:

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");

Solution:

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























id    |   data         |  confirmed 
1     | someData |      0 
2     | someData |      1 
3     | someData |      0


EmoticonEmoticon

:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
:-?
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
$-)
(y)
(f)
x-)
(k)
(h)
cheer