From 974aabe87e496477a5824d741dd2692181fefd00 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 30 Jun 2023 08:54:33 +1000 Subject: [PATCH] Add column checks prior to drops --- app/Services/Subscription/SubscriptionService.php | 4 +++- .../migrations/2023_04_27_045639_add_kmher_language.php | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/Services/Subscription/SubscriptionService.php b/app/Services/Subscription/SubscriptionService.php index 955e567f62f1..32df7b7468af 100644 --- a/app/Services/Subscription/SubscriptionService.php +++ b/app/Services/Subscription/SubscriptionService.php @@ -821,13 +821,15 @@ class SubscriptionService $invoice->is_proforma = false; $invoice->save(); + // 29-06-2023 handle webhooks for payment intent - user may not be present. + $context = [ 'context' => 'change_plan', 'recurring_invoice' => $recurring_invoice->hashed_id, 'invoice' => $this->encodePrimaryKey($payment_hash->fee_invoice_id), 'client' => $recurring_invoice->client->hashed_id, 'subscription' => $this->subscription->hashed_id, - 'contact' => auth()->guard('contact')->user()->hashed_id, + 'contact' => auth()->guard('contact')->user()?->hashed_id ?? $recurring_invoice->client->contacts()->first()->hashed_id, 'account_key' => $recurring_invoice->client->custom_value2, ]; diff --git a/database/migrations/2023_04_27_045639_add_kmher_language.php b/database/migrations/2023_04_27_045639_add_kmher_language.php index 9d2d7a994f95..69e7fb433cb3 100644 --- a/database/migrations/2023_04_27_045639_add_kmher_language.php +++ b/database/migrations/2023_04_27_045639_add_kmher_language.php @@ -25,9 +25,12 @@ return new class extends Migration Language::create(['id' => 38, 'name' => 'Khmer', 'locale' => 'km_KH']); } - Schema::table('companies', function (Blueprint $table) { - $table->dropColumn('enable_e_invoice'); - }); + if (Schema::hasColumn('companies', 'enable_e_invoice')) + { + Schema::table('companies', function (Blueprint $table) { + $table->dropColumn('enable_e_invoice'); + }); + } Company::query()->cursor()->each(function ($company){ $company->tax_data = new TaxModel();