How can I run this SQL statement with Laravel Eloquent ORM using my model?
update products set quantity = quantity + 3
How can I run this SQL statement with Laravel Eloquent ORM using my model?
update products set quantity = quantity + 3
First you need to get specific instace to change:
$product = Product::find($id);
Now, you have all attributes of object and can change loaded values:
$product->quantity += 3;
Finally, you must to save changes:
$product->save();
Then, if you check your database the value will be changed.
Ps.: using Eloquent.