From 32ff3461541279fdc5db32dcdf460e99049e9d91 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 15 May 2024 09:46:28 +0200 Subject: [PATCH] chore: Refactor Service.php to handle missing admin user in extraFields() method --- app/Models/Service.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/Models/Service.php b/app/Models/Service.php index 770dfae2e..d8950137b 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -450,14 +450,16 @@ public function extraFields() $data = collect([]); $admin_user = $this->environment_variables()->where('key', 'SERVICE_USER_ADMIN')->first(); $admin_password = $this->environment_variables()->where('key', 'SERVICE_PASSWORD_ADMIN')->first(); - $data = $data->merge([ - 'User' => [ - 'key' => 'SERVICE_USER_ADMIN', - 'value' => data_get($admin_user, 'value', 'admin'), - 'readonly' => true, - 'rules' => 'required', - ], - ]); + if ($admin_user) { + $data = $data->merge([ + 'User' => [ + 'key' => 'SERVICE_USER_ADMIN', + 'value' => data_get($admin_user, 'value', 'admin'), + 'readonly' => true, + 'rules' => 'required', + ], + ]); + } if ($admin_password) { $data = $data->merge([ 'Password' => [