diff --git a/app/Livewire/Project/Application/Advanced.php b/app/Livewire/Project/Application/Advanced.php index 3b402b3ec..2bc28026f 100644 --- a/app/Livewire/Project/Application/Advanced.php +++ b/app/Livewire/Project/Application/Advanced.php @@ -96,6 +96,20 @@ class Advanced extends Component } else { $this->application->settings->custom_internal_name = null; } + $customInternalName = $this->application->settings->custom_internal_name; + $server = $this->application->destination->server; + $allApplications = $server->applications(); + + $foundSameInternalName = $allApplications->filter(function ($application) { + return $application->id !== $this->application->id && $application->settings->custom_internal_name === $this->application->settings->custom_internal_name; + }); + if ($foundSameInternalName->isNotEmpty()) { + $this->dispatch('error', 'This custom container name is already in use by another application on this server.'); + $this->application->settings->custom_internal_name = $customInternalName; + $this->application->settings->refresh(); + + return; + } $this->application->settings->save(); $this->dispatch('success', 'Custom name saved.'); }