From 146df11c1f396b9b0ddbea59440743fcdc9c727b Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 4 Nov 2020 11:21:28 +1100 Subject: [PATCH 1/3] Refactor company logo URL --- app/Traits/GenerateMigrationResources.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Traits/GenerateMigrationResources.php b/app/Traits/GenerateMigrationResources.php index 6431a9976a3b..464202809213 100644 --- a/app/Traits/GenerateMigrationResources.php +++ b/app/Traits/GenerateMigrationResources.php @@ -99,7 +99,7 @@ trait GenerateMigrationResources 'recurring_number_prefix' => $this->account->recurring_invoice_number_prefix ? $this->account->recurring_invoice_number_prefix : 'R', 'enable_client_portal' => $this->account->enable_client_portal ? (bool) $this->account->enable_client_portal : false, 'invoice_fields' => $this->account->invoice_fields ?: '', - 'company_logo' => $this->account->logo ?: '', + 'company_logo' => $this->account->getLogoURL() ?: '', 'embed_documents' => $this->account->invoice_embed_documents ? (bool) $this->account->invoice_embed_documents : false, 'document_email_attachment' => $this->account->document_email_attachment ? (bool) $this->account->document_email_attachment : false, 'enable_client_portal_dashboard' => $this->account->enable_client_portal_dashboard ? (bool) $this->account->enable_client_portal_dashboard : true, From a86c5006af276884eb68acad285c0dde6c840116 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 4 Nov 2020 11:36:30 +1100 Subject: [PATCH 2/3] Fixes for company gateway schema --- app/Traits/GenerateMigrationResources.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Traits/GenerateMigrationResources.php b/app/Traits/GenerateMigrationResources.php index 464202809213..04b1f567f147 100644 --- a/app/Traits/GenerateMigrationResources.php +++ b/app/Traits/GenerateMigrationResources.php @@ -963,8 +963,8 @@ trait GenerateMigrationResources 'gateway_key' => $this->getGatewayKeyById($account_gateway->gateway_id), 'accepted_credit_cards' => $account_gateway->accepted_credit_cards, 'require_cvv' => $account_gateway->require_cvv, - 'show_billing_address' => $account_gateway->show_billing_address, - 'show_shipping_address' => $account_gateway->show_shipping_address, + 'require_billing_address' => $account_gateway->show_billing_address, + 'require_shipping_address' => $account_gateway->show_shipping_address, 'update_details' => $account_gateway->update_details, 'config' => Crypt::decrypt($account_gateway->config), 'fees_and_limits' => $this->transformFeesAndLimits($gateway_type_id), From a94808cf65820325170f5017b0746569392b69b3 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 16 Nov 2020 21:32:58 +1100 Subject: [PATCH 3/3] minor fixes for migration --- app/Traits/GenerateMigrationResources.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/app/Traits/GenerateMigrationResources.php b/app/Traits/GenerateMigrationResources.php index 04b1f567f147..2d63383e2040 100644 --- a/app/Traits/GenerateMigrationResources.php +++ b/app/Traits/GenerateMigrationResources.php @@ -288,7 +288,7 @@ trait GenerateMigrationResources 'first_name' => $user->first_name ?: '', 'last_name' => $user->last_name ?: '', 'phone' => $user->phone ?: '', - 'email' => $user->email, + 'email' => $user->username, 'confirmation_code' => $user->confirmation_code, 'failed_logins' => $user->failed_logins, 'referral_code' => $user->referral_code, @@ -954,6 +954,10 @@ trait GenerateMigrationResources $transformed = []; foreach ($account_gateways as $account_gateway) { + + if($account_gateway->gateway_id > 55) + continue; + $gateway_types = $account_gateway->paymentDriver()->gatewayTypes(); foreach ($gateway_types as $gateway_type_id) { @@ -988,8 +992,8 @@ trait GenerateMigrationResources $is_default = true; foreach ($payment_methods as $payment_method) { - $contact = Contact::find($payment_method->contact_id)->first(); - $agt = AccountGatewayToken::find($payment_method->account_gateway_token_id)->first(); + $contact = Contact::where('id', $payment_method->contact_id)->withTrashed()->first(); + $agt = AccountGatewayToken::where('id', $payment_method->account_gateway_token_id)->withTrashed()->first(); $transformed[] = [ 'id' => $payment_method->id, @@ -1053,7 +1057,6 @@ trait GenerateMigrationResources $status = TaskStatus::createNew(); $status->name = trans('texts.' . $defaults[$i]); $status->sort_order = $i; - $status->is_deleted = false; $status->save(); } @@ -1071,7 +1074,7 @@ trait GenerateMigrationResources 'company_id' => $this->account->id, 'user_id' => $task_status->user_id, 'status_sort_order' => $task_status->sort_order, - 'is_deleted' => $task_status->is_deleted ?: false, + 'is_deleted' => false, 'created_at' => $task_status->created_at ? $task_status->created_at->toDateString() : null, 'updated_at' => $task_status->updated_at ? $task_status->updated_at->toDateString() : null, 'deleted_at' => $task_status->deleted_at ? $task_status->deleted_at->toDateString() : null, @@ -1366,7 +1369,7 @@ trait GenerateMigrationResources private function getGatewayKeyById($gateway_id) { - $gateways = [ + $gateways = collect([ ['id' => 1, 'key' => '3b6621f970ab18887c4f6dca78d3f8bb'], ['id' => 2, 'key' => '46c5c1fed2c43acf4f379bae9c8b9f76'], ['id' => 3, 'key' => '944c20175bbe6b9972c05bcfe294c2c7'], @@ -1422,8 +1425,10 @@ trait GenerateMigrationResources ['id' => 53, 'key' => 'ef498756b54db63c143af0ec433da803'], ['id' => 54, 'key' => 'ca52f618a39367a4c944098ebf977e1c'], ['id' => 55, 'key' => '54faab2ab6e3223dbe848b1686490baa'], - ]; + ]); - return $gateways[$gateway_id]['key']; + $search = $gateways->where('id', $gateway_id)->pluck('key'); + + return $search[0]; } }