whereKey($project->id)->lockForUpdate()->firstOrFail(); $template = ProjectTemplate::query()->find($project->project_template_id); if ($template === null || $template->is_published) { return; } $template = ProjectTemplate::query()->whereKey($template->id)->lockForUpdate()->firstOrFail(); $snapshot = $this->duplicateProjectConfiguration->normalizeConfiguration($template->configuration_snapshot ?? []); $template->forceFill(['configuration_snapshot' => array_replace( $snapshot, $this->duplicateProjectConfiguration->export($project, [$area]), )])->saveQuietly(); }, 3); } }