Refactor environment variable saving logic.
This commit is contained in:
parent
eb96a5ae7b
commit
8f5b084931
@ -55,12 +55,17 @@ class All extends Component
|
|||||||
{
|
{
|
||||||
if ($isPreview) {
|
if ($isPreview) {
|
||||||
$variables = parseEnvFormatToArray($this->variablesPreview);
|
$variables = parseEnvFormatToArray($this->variablesPreview);
|
||||||
|
$this->resource->environment_variables_preview()->whereNotIn('key', array_keys($variables))->delete();
|
||||||
} else {
|
} else {
|
||||||
$variables = parseEnvFormatToArray($this->variables);
|
$variables = parseEnvFormatToArray($this->variables);
|
||||||
|
$this->resource->environment_variables()->whereNotIn('key', array_keys($variables))->delete();
|
||||||
}
|
}
|
||||||
foreach ($variables as $key => $variable) {
|
foreach ($variables as $key => $variable) {
|
||||||
|
if ($isPreview) {
|
||||||
|
$found = $this->resource->environment_variables_preview()->where('key', $key)->first();
|
||||||
|
} else {
|
||||||
$found = $this->resource->environment_variables()->where('key', $key)->first();
|
$found = $this->resource->environment_variables()->where('key', $key)->first();
|
||||||
$foundPreview = $this->resource->environment_variables_preview()->where('key', $key)->first();
|
}
|
||||||
if ($found) {
|
if ($found) {
|
||||||
if ($found->is_shown_once) {
|
if ($found->is_shown_once) {
|
||||||
continue;
|
continue;
|
||||||
@ -68,14 +73,6 @@ class All extends Component
|
|||||||
$found->value = $variable;
|
$found->value = $variable;
|
||||||
$found->save();
|
$found->save();
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
if ($foundPreview) {
|
|
||||||
if ($foundPreview->is_shown_once) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$foundPreview->value = $variable;
|
|
||||||
$foundPreview->save();
|
|
||||||
continue;
|
|
||||||
} else {
|
} else {
|
||||||
$environment = new EnvironmentVariable();
|
$environment = new EnvironmentVariable();
|
||||||
$environment->key = $key;
|
$environment->key = $key;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user