From 950278c9487c540ea9e70601c4afa8f690d42210 Mon Sep 17 00:00:00 2001 From: IceToast Date: Thu, 16 Jun 2022 11:55:34 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=E2=9C=A8=20Updated=20Migration=20to=20c?= =?UTF-8?q?alculate=20hourly=20price=20from=20existing=20products?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2022_06_16_092704_add_billing_period_to_products.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/database/migrations/2022_06_16_092704_add_billing_period_to_products.php b/database/migrations/2022_06_16_092704_add_billing_period_to_products.php index 4018fb47..708e6e5e 100644 --- a/database/migrations/2022_06_16_092704_add_billing_period_to_products.php +++ b/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"'); + + $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]); + } + } /**