From fe041730c6955c5761fb0d2dbd6efee33887be0d Mon Sep 17 00:00:00 2001 From: Luc Wollants Date: Fri, 26 Jul 2024 10:45:34 +0200 Subject: [PATCH] Allow only key visibility v2 when creating UiTPAS integration in backend --- app/Nova/Resources/Integration.php | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/app/Nova/Resources/Integration.php b/app/Nova/Resources/Integration.php index 6dff79361..6f81f67b0 100644 --- a/app/Nova/Resources/Integration.php +++ b/app/Nova/Resources/Integration.php @@ -119,12 +119,24 @@ public function fields(NovaRequest $request): array Select::make('Key Visibility') ->filterable() ->sortable() - ->options([ - KeyVisibility::v1->value => KeyVisibility::v1->name, - KeyVisibility::v2->value => KeyVisibility::v2->name, - KeyVisibility::all->value => KeyVisibility::all->name, - ]) - ->rules('required'), + ->required() + ->dependsOn( + ['type'], + function (Select $field, NovaRequest $request, FormData $formData) { + if ($formData->string('type')->toString() !== IntegrationType::UiTPAS->value) { + $field->options([ + KeyVisibility::v1->value => KeyVisibility::v1->name, + KeyVisibility::v2->value => KeyVisibility::v2->name, + KeyVisibility::all->value => KeyVisibility::all->name, + ]); + return; + } + + $field->options([ + KeyVisibility::v2->value => KeyVisibility::v2->name, + ]); + } + ), Text::make('Description') ->rules('required', 'max:255')