Laravel incremnt值柱

代码示例

1
0

增量单列laravel

Product::increment('count' , 5); // count + 5

Product::decrement('count', 5); // count - 5

---------------Or-----------------------
  
Product::where('product_id', $product->id)
    ->update([
      'count'=> DB::raw('count+1'), 
      'last_count_increased_at' => Carbon::now()
    ]);
1
0

增laravel

$customer = Customer::find($customer_id);
$loyalty_points = $customer->loyalty_points + 1;
$customer->update(['loyalty_points' => $loyalty_points]);

or

Customer::find($customer_id)->increment('loyalty_points');

其他语言

此页面有其他语言版本

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................