Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

abhishek88's avatar

Laravel update query (Add a value to existing a value)

How we update value to add exiting value in laravel

suppose we have fee column in table

we update in first time it value will be 1000

then next time we update value 500

it will be sum =1000+500=1500

i use this query

$pay->paying = $request->paying += 500;

but it update only fix value 500

we update using form

0 likes
2 replies
amirkamizi's avatar
Level 3

$pay->paying = $request->paying += 500;

every time you refresh the page the $request->paying is back to the initial value. you should add the +500 to the $pay->paying

$oldPaying = $pay->paying;
$pay->paying = $oldPaying + 500;

Or take a look at the link that @sr57 sent. laravel has increment and decrement on models which you can use.

Please or to participate in this conversation.