From 1800f105d73c718b1bc072ea8b5ad57333ebad98 Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Thu, 25 Apr 2024 20:31:46 -0400 Subject: [PATCH] Simplify logic greatly --- .../ServerResource/Pages/CreateServer.php | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/app/Filament/Resources/ServerResource/Pages/CreateServer.php b/app/Filament/Resources/ServerResource/Pages/CreateServer.php index 4d52ef351..0371aec37 100644 --- a/app/Filament/Resources/ServerResource/Pages/CreateServer.php +++ b/app/Filament/Resources/ServerResource/Pages/CreateServer.php @@ -219,24 +219,13 @@ class CreateServer extends CreateRecord ($allocation->ip_alias ? " ($allocation->ip_alias)" : '') ) ->placeholder('Select additional Allocations') + ->disableOptionsWhenSelectedInSiblingRepeaterItems() ->relationship( 'allocations', 'ip', fn (Builder $query, Forms\Get $get, Forms\Components\Select $component, $state) => $query ->where('node_id', $get('../../node_id')) - ->whereNotIn( - 'id', - collect(($repeater = $component->getParentRepeater())->getState()) - ->pluck( - (string) str($component->getStatePath()) - ->after("{$repeater->getStatePath()}.") - ->after('.'), - ) - ->flatten() - ->diff(Arr::wrap($state)) - ->filter(fn (mixed $siblingItemState): bool => filled($siblingItemState)) - ->add($get('../../allocation_id')) - ) + ->whereNot('id', $get('../../allocation_id')) ->whereNull('server_id'), ), ),