瀏覽代碼

fix: ✨ Updated Migration to calculate hourly price from existing products

IceToast 3 年之前
父節點
當前提交
950278c948
共有 1 個文件被更改,包括 8 次插入0 次删除
  1. 8 0
      database/migrations/2022_06_16_092704_add_billing_period_to_products.php

+ 8 - 0
database/migrations/2022_06_16_092704_add_billing_period_to_products.php

@@ -19,6 +19,14 @@ class AddBillingPeriodToProducts extends Migration
         });
         });
 
 
         DB::statement('UPDATE products SET billing_period="hourly"');
         DB::statement('UPDATE products SET billing_period="hourly"');
+
+        $products = DB::table('products')->get();
+        foreach ($products as $product) {
+            $price = $product->price;
+            $price = $price / 30 / 24;
+            DB::table('products')->where('id', $product->id)->update(['price' => $price]);
+        }
+
     }
     }
 
 
     /**
     /**