What I want to do is the equivalent of this consultation using Eloquent, but I have no idea how to do it.
update promociones set veces_cajeadas=veces_cajeadas + 1 where id = 7
What I need is that when a specific promotion id is chosen, add 1 to a field in the table. The model for the table is Promotions.
in laravel eloquent and even query builder, there is a convenient way to decrease and increase values of model
$promotions = Promotions::find($id);
$promotions->increment('veces_cajeadas')
for more information about these methods you can read laravel doc
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.