3

I'm trying to Sum the value from database to other value. But It keeps only insert the value not the sum of the value. Any ideas?

foreach ($isisjkirims as $key => $isisjkirim)  
{  
  IsiSJKirim::where('IsiSJKir', $isisjkir[$key])  
  ->update(['QSisaKemInsert' => 'QSisaKemInsert' + $qtertanda[$key]]);  
}                                      ^
                                i think this one
0

1 Answer 1

4

You need to get data first and then update:

$data = IsiSJKirim::where('IsiSJKir', $isisjkir[$key])->first();
$data->update(['QSisaKemInsert' => (int)$data->QSisaKemInsert + (int)$qtertanda[$key]]);
Sign up to request clarification or add additional context in comments.

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.