I would like to perform an UPDATE
using Eloquent, that will set column_c
value using values of column_a
and column_b
of the same table. Basically, something like this:
User::where('id', '>', 0)
->update(['column_c' => $this->column_a + $this->column_b]);
where $this->column_a
and $this->column_b
would be the actual values from the current row.
MySQL equivalent:
UPDATE `user` WHERE id > 0 SET column_c = column_a + column_b;
Note: The code above is just an example to show the idea. It's not the actual implementation (which would be creating a DB redundancy).
How do I perform such update in Laravel 5.1? I would really like to avoid a foreach
.