0

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

1
  • 2
    try this: Employee::find($employee_id)->increment('bonus', 10); Commented Sep 13, 2017 at 5:13

2 Answers 2

1

Try this:

DB::table('employee')->increment('bonus', 10);
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.