Fix some data integrity issues

This commit is contained in:
Dane Everitt 2018-02-17 13:37:53 -06:00
parent d52f8d9215
commit 241f7d0125
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
6 changed files with 41 additions and 37 deletions

View file

@ -44,10 +44,15 @@ class VariableCreationService
$options = array_get($data, 'options') ?? [];
return $this->repository->create(array_merge($data, [
return $this->repository->create([
'egg_id' => $egg,
'name' => $data['name'] ?? '',
'description' => $data['description'] ?? '',
'env_variable' => $data['env_variable'] ?? '',
'default_value' => $data['default_value'] ?? '',
'user_viewable' => in_array('user_viewable', $options),
'user_editable' => in_array('user_editable', $options),
]));
'rules' => $data['rules'] ?? '',
]);
}
}

View file

@ -46,7 +46,7 @@ class VariableUpdateService
}
$search = $this->repository->setColumns('id')->findCountWhere([
['env_variable', '=', array_get($data, 'env_variable')],
['env_variable', '=', $data['env_variable']],
['egg_id', '=', $variable->egg_id],
['id', '!=', $variable->id],
]);
@ -60,10 +60,14 @@ class VariableUpdateService
$options = array_get($data, 'options') ?? [];
return $this->repository->withoutFreshModel()->update($variable->id, array_merge($data, [
'default_value' => array_get($data, 'default_value') ?? '',
return $this->repository->withoutFreshModel()->update($variable->id, [
'name' => $data['name'] ?? '',
'description' => $data['description'] ?? '',
'env_variable' => $data['env_variable'] ?? '',
'default_value' => $data['default_value'] ?? '',
'user_viewable' => in_array('user_viewable', $options),
'user_editable' => in_array('user_editable', $options),
]));
'rules' => $data['rules'] ?? '',
]);
}
}