chore: Refactor Service.php to handle missing admin user in extraFields() method

This commit is contained in:
Andras Bacsai 2024-05-15 09:46:28 +02:00
parent 0008f44255
commit 32ff346154

View File

@ -450,14 +450,16 @@ public function extraFields()
$data = collect([]); $data = collect([]);
$admin_user = $this->environment_variables()->where('key', 'SERVICE_USER_ADMIN')->first(); $admin_user = $this->environment_variables()->where('key', 'SERVICE_USER_ADMIN')->first();
$admin_password = $this->environment_variables()->where('key', 'SERVICE_PASSWORD_ADMIN')->first(); $admin_password = $this->environment_variables()->where('key', 'SERVICE_PASSWORD_ADMIN')->first();
$data = $data->merge([ if ($admin_user) {
'User' => [ $data = $data->merge([
'key' => 'SERVICE_USER_ADMIN', 'User' => [
'value' => data_get($admin_user, 'value', 'admin'), 'key' => 'SERVICE_USER_ADMIN',
'readonly' => true, 'value' => data_get($admin_user, 'value', 'admin'),
'rules' => 'required', 'readonly' => true,
], 'rules' => 'required',
]); ],
]);
}
if ($admin_password) { if ($admin_password) {
$data = $data->merge([ $data = $data->merge([
'Password' => [ 'Password' => [