diff --git a/app/Http/Controllers/Api/Applications.php b/app/Http/Controllers/Api/Applications.php index 8bbb14a07..82fde140c 100644 --- a/app/Http/Controllers/Api/Applications.php +++ b/app/Http/Controllers/Api/Applications.php @@ -276,7 +276,7 @@ public function envs_by_uuid(Request $request) public function update_env_by_uuid(Request $request) { ray()->clearAll(); - $allowedFields = ['key', 'value', 'is_preview', 'is_build_time', 'is_literal', 'both']; + $allowedFields = ['key', 'value', 'is_preview', 'is_build_time', 'is_literal']; $teamId = get_team_id_from_token(); if (is_null($teamId)) { @@ -296,7 +296,6 @@ public function update_env_by_uuid(Request $request) 'is_preview' => 'boolean', 'is_build_time' => 'boolean', 'is_literal' => 'boolean', - 'both' => 'boolean', ]); $extraFields = array_diff(array_keys($request->all()), $allowedFields); @@ -316,37 +315,6 @@ public function update_env_by_uuid(Request $request) $is_preview = $request->is_preview ?? false; $is_build_time = $request->is_build_time ?? false; $is_literal = $request->is_literal ?? false; - $both = $request->both ?? false; - if ($both) { - $env = $application->environment_variables_preview->where('key', $request->key)->first(); - if ($env) { - $env->value = $request->value; - if ($env->is_build_time != $is_build_time) { - $env->is_build_time = $is_build_time; - } - if ($env->is_literal != $is_literal) { - $env->is_literal = $is_literal; - } - ray($env); - $env->save(); - } - - $env = $application->environment_variables->where('key', $request->key)->first(); - if ($env) { - $env->value = $request->value; - if ($env->is_build_time != $is_build_time) { - $env->is_build_time = $is_build_time; - } - if ($env->is_literal != $is_literal) { - $env->is_literal = $is_literal; - } - $env->save(); - } - - return response()->json([ - 'message' => 'Environment variables updated.', - ]); - } if ($is_preview) { $env = $application->environment_variables_preview->where('key', $request->key)->first(); if ($env) { @@ -423,7 +391,7 @@ public function create_bulk_envs(Request $request) ], 400); } $bulk_data = collect($bulk_data)->map(function ($item) { - return collect($item)->only(['key', 'value', 'is_preview', 'is_build_time', 'is_literal', 'both']); + return collect($item)->only(['key', 'value', 'is_preview', 'is_build_time', 'is_literal']); }); foreach ($bulk_data as $item) { $validator = customApiValidator($item, [ @@ -432,7 +400,6 @@ public function create_bulk_envs(Request $request) 'is_preview' => 'boolean', 'is_build_time' => 'boolean', 'is_literal' => 'boolean', - 'both' => 'boolean', ]); if ($validator->fails()) { return response()->json([ @@ -443,50 +410,6 @@ public function create_bulk_envs(Request $request) $is_preview = $item->get('is_preview') ?? false; $is_build_time = $item->get('is_build_time') ?? false; $is_literal = $item->get('is_literal') ?? false; - $both = $item->get('both') ?? false; - if ($both) { - $env = $application->environment_variables_preview->where('key', $item->get('key'))->first(); - if ($env) { - $env->value = $item->get('value'); - if ($env->is_build_time != $is_build_time) { - $env->is_build_time = $is_build_time; - } - if ($env->is_literal != $is_literal) { - $env->is_literal = $is_literal; - } - $env->save(); - } else { - $env = $application->environment_variables()->create([ - 'key' => $item->get('key'), - 'value' => $item->get('value'), - 'is_preview' => $is_preview, - 'is_build_time' => $is_build_time, - 'is_literal' => $is_literal, - ]); - } - - $env = $application->environment_variables->where('key', $item->get('key'))->first(); - if ($env) { - $env->value = $item->get('value'); - if ($env->is_build_time != $is_build_time) { - $env->is_build_time = $is_build_time; - } - if ($env->is_literal != $is_literal) { - $env->is_literal = $is_literal; - } - $env->save(); - } else { - $env = $application->environment_variables()->create([ - 'key' => $item->get('key'), - 'value' => $item->get('value'), - 'is_preview' => $is_preview, - 'is_build_time' => $is_build_time, - 'is_literal' => $is_literal, - ]); - } - - continue; - } if ($is_preview) { $env = $application->environment_variables_preview->where('key', $item->get('key'))->first(); if ($env) { @@ -622,7 +545,6 @@ public function delete_env_by_uuid(Request $request) { ray()->clearAll(); $teamId = get_team_id_from_token(); - $both = $request->query->get('both') ?? false; if (is_null($teamId)) { return invalid_token(); } @@ -642,12 +564,6 @@ public function delete_env_by_uuid(Request $request) ], 404); } $found_env->delete(); - if ($both) { - $found_other_pair = EnvironmentVariable::where('application_id', $application->id)->where('key', $found_env->key)->first(); - if ($found_other_pair) { - $found_other_pair->delete(); - } - } return response()->json([ 'success' => true, diff --git a/app/Http/Controllers/Api/EnvironmentVariables.php b/app/Http/Controllers/Api/EnvironmentVariables.php index d27d4f501..d788bdb0c 100644 --- a/app/Http/Controllers/Api/EnvironmentVariables.php +++ b/app/Http/Controllers/Api/EnvironmentVariables.php @@ -12,7 +12,6 @@ public function delete_env_by_uuid(Request $request) { ray()->clearAll(); $teamId = get_team_id_from_token(); - $both = $request->query->get('both') ?? false; if (is_null($teamId)) { return invalid_token(); } @@ -31,12 +30,6 @@ public function delete_env_by_uuid(Request $request) ], 404); } $env->delete(); - if ($both) { - $found_other_pair = EnvironmentVariable::where('application_id', $found_app->id)->where('key', $env->key)->first(); - if ($found_other_pair) { - $found_other_pair->delete(); - } - } return response()->json([ 'success' => true,