Move remaining project metadata ownership to templates
This commit is contained in:
@@ -27,6 +27,13 @@ class CreateProject
|
||||
{
|
||||
return DB::transaction(function () use ($attributes, $actor): Project {
|
||||
$project = Project::query()->create(Arr::only($attributes, ['key', 'name']));
|
||||
$baseTemplate = $this->createProjectBaseTemplate->handle($project);
|
||||
|
||||
$project->forceFill([
|
||||
'project_template_id' => $baseTemplate->id,
|
||||
])->save();
|
||||
|
||||
$project = $project->fresh() ?? $project;
|
||||
|
||||
$this->initializeProjectTicketMetadata->handle($project);
|
||||
$this->permissionService->grant($actor, Permission::ProjectAdmin, $project);
|
||||
@@ -50,19 +57,14 @@ class CreateProject
|
||||
$project,
|
||||
$template->configuration_snapshot ?? [],
|
||||
);
|
||||
|
||||
$project->forceFill([
|
||||
'project_template_id' => $template->id,
|
||||
])->save();
|
||||
}
|
||||
|
||||
if ($project->project_template_id === null) {
|
||||
$baseTemplate = $this->createProjectBaseTemplate->handle($project->fresh() ?? $project);
|
||||
|
||||
$project->forceFill([
|
||||
'project_template_id' => $baseTemplate->id,
|
||||
])->save();
|
||||
}
|
||||
$baseTemplate->forceFill([
|
||||
'configuration_snapshot' => $this->duplicateProjectConfiguration->export(
|
||||
$project->fresh() ?? $project,
|
||||
DuplicateProjectConfiguration::copyableAreas(),
|
||||
),
|
||||
])->save();
|
||||
|
||||
return $project->fresh() ?? $project;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user