From c5528a61f37c743382acbf41bf3584be8e65b98e Mon Sep 17 00:00:00 2001 From: MartinOscar <40749467+rmartinoscar@users.noreply.github.com> Date: Thu, 10 Jul 2025 08:59:46 +0200 Subject: [PATCH] Filter out already used ips with the same port (#1496) --- .../RelationManagers/AllocationsRelationManager.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/Filament/Admin/Resources/NodeResource/RelationManagers/AllocationsRelationManager.php b/app/Filament/Admin/Resources/NodeResource/RelationManagers/AllocationsRelationManager.php index 020d4eb39..1bcf712fd 100644 --- a/app/Filament/Admin/Resources/NodeResource/RelationManagers/AllocationsRelationManager.php +++ b/app/Filament/Admin/Resources/NodeResource/RelationManagers/AllocationsRelationManager.php @@ -62,7 +62,16 @@ class AllocationsRelationManager extends RelationManager ->label(trans('admin/node.table.allocation_notes')) ->placeholder(trans('admin/node.table.no_notes')), SelectColumn::make('ip') - ->options(fn (Allocation $allocation) => collect($this->getOwnerRecord()->ipAddresses())->merge([$allocation->ip])->mapWithKeys(fn (string $ip) => [$ip => $ip])) + ->options(function (Allocation $allocation) { + $ips = Allocation::where('port', $allocation->port)->pluck('ip'); + + return collect($this->getOwnerRecord()->ipAddresses()) + ->diff($ips) + ->unshift($allocation->ip) + ->unique() + ->mapWithKeys(fn (string $ip) => [$ip => $ip]) + ->all(); + }) ->selectablePlaceholder(false) ->searchable() ->label(trans('admin/node.table.ip')),