revert query logic

This commit is contained in:
Andras Bacsai
2024-12-03 14:02:12 +01:00
parent 7b0a902f25
commit 869eaedaf5

View File

@@ -16,24 +16,26 @@ class Configuration extends Component
public function mount() public function mount()
{ {
$this->application = Application::query() $project = currentTeam()
->whereHas('environment.project', function ($query) { ->projects()
$query->where('team_id', currentTeam()->id) ->select('id', 'uuid', 'team_id')
->where('uuid', request()->route('project_uuid')); ->where('uuid', request()->route('project_uuid'))
}) ->firstOrFail();
->whereHas('environment', function ($query) { $environment = $project->environments()
$query->where('name', request()->route('environment_name')); ->select('id', 'name', 'project_id')
}) ->where('name', request()->route('environment_name'))
->firstOrFail();
$application = $environment->applications()
->with(['destination'])
->where('uuid', request()->route('application_uuid')) ->where('uuid', request()->route('application_uuid'))
->with(['destination' => function ($query) {
$query->select('id', 'server_id');
}])
->firstOrFail(); ->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() $this->servers = Server::ownedByCurrentTeam()
->select('id', 'name') ->select('id', 'name')
->where('id', '!=', $this->application->destination->server_id) ->where('id', '!=', $mainServer->id)
->get(); ->get();
} else { } else {
$this->servers = collect(); $this->servers = collect();