我想做的就是相當于這個使用Eloquent的咨詢,但是我不知道怎么做。update promociones set veces_cajeadas=veces_cajeadas + 1 where id = 7What I need is that when a specific promotion id is chosen, add 1 to a field in the table. 該表的模型是促銷。
1 回答

慕容森
TA貢獻1853條經驗 獲得超18個贊
在 laravel eloquent 甚至查詢生成器中,有一種方便的方法來減少和增加模型的值
$promotions = Promotions::find($id);
$promotions->increment('veces_cajeadas')
有關這些方法的更多信息,您可以閱讀laravel doc
- 1 回答
- 0 關注
- 180 瀏覽
添加回答
舉報
0/150
提交
取消