From 4b0f65c9269842edc51d42c04c63b62d6f583eca Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Fri, 3 Oct 2025 10:15:47 +0200 Subject: [PATCH] refactor(environment-variables): adjust ordering logic for environment variables - Updated the ordering logic in the environment_variables methods for both Application and Service models to prioritize required variables over service-prefixed keys. - This change enhances the clarity and organization of environment variable retrieval, ensuring that essential variables are listed first. --- app/Models/Application.php | 12 ++++++------ app/Models/Service.php | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/Models/Application.php b/app/Models/Application.php index 4f1796790..914d9948d 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -739,9 +739,9 @@ public function environment_variables() return $this->morphMany(EnvironmentVariable::class, 'resourceable') ->where('is_preview', false) ->orderByRaw(" - CASE - WHEN LOWER(key) LIKE 'service_%' THEN 1 - WHEN is_required = true AND (value IS NULL OR value = '') THEN 2 + CASE + WHEN is_required = true THEN 1 + WHEN LOWER(key) LIKE 'service_%' THEN 2 ELSE 3 END, LOWER(key) ASC @@ -767,9 +767,9 @@ public function environment_variables_preview() return $this->morphMany(EnvironmentVariable::class, 'resourceable') ->where('is_preview', true) ->orderByRaw(" - CASE - WHEN LOWER(key) LIKE 'service_%' THEN 1 - WHEN is_required = true AND (value IS NULL OR value = '') THEN 2 + CASE + WHEN is_required = true THEN 1 + WHEN LOWER(key) LIKE 'service_%' THEN 2 ELSE 3 END, LOWER(key) ASC diff --git a/app/Models/Service.php b/app/Models/Service.php index c9bf4cbcd..063c8cba4 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -1231,9 +1231,9 @@ public function environment_variables() { return $this->morphMany(EnvironmentVariable::class, 'resourceable') ->orderByRaw(" - CASE - WHEN LOWER(key) LIKE 'service_%' THEN 1 - WHEN is_required = true AND (value IS NULL OR value = '') THEN 2 + CASE + WHEN is_required = true THEN 1 + WHEN LOWER(key) LIKE 'service_%' THEN 2 ELSE 3 END, LOWER(key) ASC