From 869eaedaf57d04d17a71f91b3a53f10e9a36f423 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 3 Dec 2024 14:02:12 +0100 Subject: [PATCH] revert query logic --- .../Project/Application/Configuration.php | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/app/Livewire/Project/Application/Configuration.php b/app/Livewire/Project/Application/Configuration.php index cce3bdd39..5261a0800 100644 --- a/app/Livewire/Project/Application/Configuration.php +++ b/app/Livewire/Project/Application/Configuration.php @@ -16,24 +16,26 @@ class Configuration extends Component public function mount() { - $this->application = Application::query() - ->whereHas('environment.project', function ($query) { - $query->where('team_id', currentTeam()->id) - ->where('uuid', request()->route('project_uuid')); - }) - ->whereHas('environment', function ($query) { - $query->where('name', request()->route('environment_name')); - }) + $project = currentTeam() + ->projects() + ->select('id', 'uuid', 'team_id') + ->where('uuid', request()->route('project_uuid')) + ->firstOrFail(); + $environment = $project->environments() + ->select('id', 'name', 'project_id') + ->where('name', request()->route('environment_name')) + ->firstOrFail(); + $application = $environment->applications() + ->with(['destination']) ->where('uuid', request()->route('application_uuid')) - ->with(['destination' => function ($query) { - $query->select('id', 'server_id'); - }]) ->firstOrFail(); - if ($this->application->destination && $this->application->destination->server_id) { + $this->application = $application; + if ($application->destination && $application->destination->server) { + $mainServer = $application->destination->server; $this->servers = Server::ownedByCurrentTeam() ->select('id', 'name') - ->where('id', '!=', $this->application->destination->server_id) + ->where('id', '!=', $mainServer->id) ->get(); } else { $this->servers = collect();