Skip to content

Commit

Permalink
fix duplicat title on projects
Browse files Browse the repository at this point in the history
  • Loading branch information
gheorghelupu17 committed Oct 12, 2023
1 parent 1ab0329 commit 37e0e8c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 6 additions & 1 deletion app/Services/ProjectService.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ private function createDraftProject(array $data): Project|RegionalProject
if (empty($data['name'])) {
$data['name'] = 'Draft-' . date('Y-m-d H:i:s') . '-' . auth()->user()->name;
}
$data['slug'] = \Str::slug($data['name']);
$slug = \Str::slug($data['name']);
$count = Project::whereRaw("slug RLIKE '^{$slug}(-[0-9]+)?$'")->count();
$data['slug'] = $slug;
if ($count > 0) {
$data['slug'] .= '-' . ($count + 1);
}

return $this->project::create($data);
}
Expand Down
1 change: 0 additions & 1 deletion resources/js/Components/form/Textarea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<span v-if="label">{{ label }}</span>
<span v-else><slot /></span>
<slot />

</label>

<div>
Expand Down

0 comments on commit 37e0e8c

Please sign in to comment.