[英]How to make a query with Eloquent in Laravel 5.8?
What I want to do is the equivalent of this consultation using Eloquent, but I have no idea how to do it. 我想做的事情等同于使用Eloquent进行咨询,但是我不知道该怎么做。
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. 我需要的是,当选择特定的促销ID时,将1添加到表中的字段。 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 在laravel雄辩甚至查询的构建器中,有一种方便的方法来减少和增加模型的值
$promotions = Promotions::find($id);
$promotions->increment('veces_cajeadas')
for more information about these methods you can read laravel doc 有关这些方法的更多信息,您可以阅读laravel doc
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.