lalalala lalalala - 5 months ago 48
PHP Question

Sum value from db in laravel

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


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