From 2dc4f37624ddec2605a08462c88bb97dc7cf9a0d Mon Sep 17 00:00:00 2001 From: Luc Wollants Date: Wed, 22 May 2024 11:33:43 +0200 Subject: [PATCH 1/3] Make website nullable --- app/Nova/Resources/Integration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Nova/Resources/Integration.php b/app/Nova/Resources/Integration.php index a41b24b7a..7224a442e 100644 --- a/app/Nova/Resources/Integration.php +++ b/app/Nova/Resources/Integration.php @@ -132,7 +132,7 @@ public function fields(NovaRequest $request): array URL::make('Website') ->displayUsing(fn () => $this->website) ->showOnIndex(false) - ->rules('url:http,https', 'max:255'), + ->rules('nullable', 'url:http,https', 'max:255'), BelongsTo::make('Organization') ->withoutTrashed() From bda00cf1e8ccc93d18a1ba19b5f4fc39079723a6 Mon Sep 17 00:00:00 2001 From: Luc Wollants Date: Wed, 22 May 2024 11:34:07 +0200 Subject: [PATCH 2/3] Handle empty website as `-` to clear it once set --- app/Insightly/Serializers/CustomFields/WebsiteSerializer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Insightly/Serializers/CustomFields/WebsiteSerializer.php b/app/Insightly/Serializers/CustomFields/WebsiteSerializer.php index 12b8d9680..74f4f6fa1 100644 --- a/app/Insightly/Serializers/CustomFields/WebsiteSerializer.php +++ b/app/Insightly/Serializers/CustomFields/WebsiteSerializer.php @@ -10,12 +10,12 @@ final class WebsiteSerializer { public const CUSTOM_FIELD_WEBSITE = 'URL_agenda__c'; - public function toInsightlyArray(Website $website): array + public function toInsightlyArray(?Website $website): array { return [ 'FIELD_NAME' => self::CUSTOM_FIELD_WEBSITE, 'CUSTOM_FIELD_ID' => self::CUSTOM_FIELD_WEBSITE, - 'FIELD_VALUE' => $website->value, + 'FIELD_VALUE' => $website ? $website->value : '-', ]; } } From 107a64dbb0101a2fdbac28ba367b23b37540ca1f Mon Sep 17 00:00:00 2001 From: Luc Wollants Date: Wed, 22 May 2024 11:34:31 +0200 Subject: [PATCH 3/3] Pass website even when it's empty to force a clear --- app/Insightly/Serializers/OpportunitySerializer.php | 5 +---- app/Insightly/Serializers/ProjectSerializer.php | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/app/Insightly/Serializers/OpportunitySerializer.php b/app/Insightly/Serializers/OpportunitySerializer.php index 15f3a3a91..8678027f4 100644 --- a/app/Insightly/Serializers/OpportunitySerializer.php +++ b/app/Insightly/Serializers/OpportunitySerializer.php @@ -27,13 +27,10 @@ public function toInsightlyArray(Integration $integration): array 'STAGE_ID' => $this->pipelines->getOpportunityStageId(OpportunityStage::TEST), 'CUSTOMFIELDS' => [ (new IntegrationTypeSerializer())->toInsightlyArray($integration->type), + (new WebsiteSerializer())->toInsightlyArray($integration->website()), ], ]; - if ($integration->website()) { - $insightlyArray['CUSTOMFIELDS'][] = (new WebsiteSerializer())->toInsightlyArray($integration->website()); - } - return $insightlyArray; } diff --git a/app/Insightly/Serializers/ProjectSerializer.php b/app/Insightly/Serializers/ProjectSerializer.php index 6b6061c52..a897d2028 100644 --- a/app/Insightly/Serializers/ProjectSerializer.php +++ b/app/Insightly/Serializers/ProjectSerializer.php @@ -27,13 +27,10 @@ public function toInsightlyArray(Integration $integration): array 'STAGE_ID' => $this->pipelines->getProjectStageId(ProjectStage::TEST), 'CUSTOMFIELDS' => [ (new IntegrationTypeSerializer())->toInsightlyArray($integration->type), + (new WebsiteSerializer())->toInsightlyArray($integration->website()), ], ]; - if ($integration->website()) { - $insightlyArray['CUSTOMFIELDS'][] = (new WebsiteSerializer())->toInsightlyArray($integration->website()); - } - return $insightlyArray; }