I want to add 10 from a current database value.
Current db value = 20;adding = 10;updated value 30;
The following code is not working.
DB::table('employee')->increment('bonus'=>'bonus+10');
-
2try this: Employee::find($employee_id)->increment('bonus', 10);Kannan K– Kannan K2017-09-13 05:13:40 +00:00Commented Sep 13, 2017 at 5:13
Add a comment
|
2 Answers
Try this -
DB::table('employee')->increment('bonus', 10);
You can do like this as well:
DB::table('employee')
->where('rowID', 1) // if you to add in a perticular table else comment it for updating entire column's value by adding 10 in it.
->update([
'bonus' => DB::raw('bonus + 10'),
]);
Hope this will help you.