Level 39
Have a look here
https://laravel.com/docs/8.x/queries#increment-and-decrement
Summer Sale! All accounts are 50% off this week.
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
$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.