An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
refactor(clone): enhance application cloning by separating production and preview environment variable handling
Andras Bacsaiff29525dd957
diff --git a/bootstrap/helpers/applications.php b/bootstrap/helpers/applications.phpindex ca34875d82..db7767c1eb 100644--- a/bootstrap/helpers/applications.php+++ b/bootstrap/helpers/applications.php@@ -317,18 +317,38 @@ function clone_application(Application $source, $destination, array $overrides =$newStorage->save();}- // Clone environment variables+ // Clone production environment variables without triggering the created hook$environmentVariables = $source->environment_variables()->get();foreach ($environmentVariables as $environmentVariable) {- $newEnvironmentVariable = $environmentVariable->replicate([- 'id',- 'created_at',- 'updated_at',- ])->fill([- 'resourceable_id' => $newApplication->id,- 'resourceable_type' => $newApplication->getMorphClass(),- ]);- $newEnvironmentVariable->save();+ \App\Models\EnvironmentVariable::withoutEvents(function () use ($environmentVariable, $newApplication) {+ $newEnvironmentVariable = $environmentVariable->replicate([+ 'id',+ 'created_at',+ 'updated_at',+ ])->fill([+ 'resourceable_id' => $newApplication->id,+ 'resourceable_type' => $newApplication->getMorphClass(),+ 'is_preview' => false,+ ]);+ $newEnvironmentVariable->save();+ });+ }++ // Clone preview environment variables+ $previewEnvironmentVariables = $source->environment_variables_preview()->get();+ foreach ($previewEnvironmentVariables as $previewEnvironmentVariable) {+ \App\Models\EnvironmentVariable::withoutEvents(function () use ($previewEnvironmentVariable, $newApplication) {+ $newPreviewEnvironmentVariable = $previewEnvironmentVariable->replicate([+ 'id',+ 'created_at',+ 'updated_at',+ ])->fill([+ 'resourceable_id' => $newApplication->id,+ 'resourceable_type' => $newApplication->getMorphClass(),+ 'is_preview' => true,+ ]);+ $newPreviewEnvironmentVariable->save();+ });}return $newApplication;