Esempio n. 1
0
 public static function updateStock($productId)
 {
     $product = Products::find($productId);
     $stockQuantity = Stocks::whereProductId($productId)->sum('quantity');
     $soldQuantity = SalesItems::where('product_id', '=', $productId)->sum('quantity');
     $product->quantity = $stockQuantity - $soldQuantity;
     $product->save();
 }