From 2558ee965c76b3055cbee7fb4dc7c8929b5651b5 Mon Sep 17 00:00:00 2001 From: Mike Gilfillan Date: Wed, 26 Mar 2025 13:42:41 +0000 Subject: [PATCH] Replace env() usage within app (#735) env() will always return the default value when used outside of config files if the config has been cached --- api/app/Models/Forms/Form.php | 2 +- api/app/Service/Forms/FormLogicConditionChecker.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/app/Models/Forms/Form.php b/api/app/Models/Forms/Form.php index 49e4e049..5f49caa2 100644 --- a/api/app/Models/Forms/Form.php +++ b/api/app/Models/Forms/Form.php @@ -179,7 +179,7 @@ class Form extends Model implements CachableAttributes public function getViewsCountAttribute() { return $this->remember('views_count', 15 * 60, function (): int { - if (env('DB_CONNECTION') == 'mysql') { + if (config('database.default') === 'mysql') { return (int) ($this->views()->count() + $this->statistics()->sum(DB::raw("json_extract(data, '$.views')"))); } diff --git a/api/app/Service/Forms/FormLogicConditionChecker.php b/api/app/Service/Forms/FormLogicConditionChecker.php index 707b1ffc..db77742c 100644 --- a/api/app/Service/Forms/FormLogicConditionChecker.php +++ b/api/app/Service/Forms/FormLogicConditionChecker.php @@ -321,7 +321,7 @@ class FormLogicConditionChecker ->where(function ($query) use ($condition, $fieldValue) { $fieldId = $condition['property_meta']['id']; - if (env('DB_CONNECTION') == 'mysql') { + if (config('database.default') === 'mysql') { // For scalar values $query->where(function ($q) use ($fieldId, $fieldValue) { $q->whereRaw("JSON_UNQUOTE(JSON_EXTRACT(data, '$.\"$fieldId\"')) = ?", [$fieldValue]);