Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

update eloquent with increment laravel

Product::where('id',$id)
->increment('quantity', 4, ['updated_at' => Carbon::now()]);
or
// Increment by 1
Product::find($product_id)->increment('quantity');
//Increment by entered number "2"
Product::find($product_id)->increment('quantity', 2);
or
// Increment by 1
DB::table('products')->increment('quantity');
//Increment by entered number "2"
DB::table('products')->increment('quantity', 2);
  
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #update #eloquent #increment #laravel
ADD COMMENT
Topic
Name
6+4 =