“Laravel eloquent Inkrement” Code-Antworten

Laravel eloquent Inkrement

Customer::find($customer_id)->increment('loyalty_points');
  
  
// increment by 20 
  Customer::find($customer_id)->increment('loyalty_points',20);
Abdullah Mohamed

Aktualisieren Sie eloquent mit 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);
  
Snippets

Inkrement 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');
Mohamad

Ähnliche Antworten wie “Laravel eloquent Inkrement”

Fragen ähnlich wie “Laravel eloquent Inkrement”

Weitere verwandte Antworten zu “Laravel eloquent Inkrement” auf PHP

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen