Implement creator studio and upload updates
This commit is contained in:
@@ -14,7 +14,7 @@ final class ArtworkDraftService
|
||||
public function createDraft(int $userId, string $title, ?string $description, ?int $categoryId = null, bool $isMature = false): ArtworkDraftResult
|
||||
{
|
||||
return DB::transaction(function () use ($userId, $title, $description, $categoryId, $isMature) {
|
||||
$slug = $this->uniqueSlug($title);
|
||||
$slug = $this->makeSlug($title);
|
||||
|
||||
$artwork = Artwork::create([
|
||||
'user_id' => $userId,
|
||||
@@ -44,20 +44,10 @@ final class ArtworkDraftService
|
||||
});
|
||||
}
|
||||
|
||||
private function uniqueSlug(string $title): string
|
||||
private function makeSlug(string $title): string
|
||||
{
|
||||
$base = Str::slug($title);
|
||||
$base = $base !== '' ? $base : 'artwork';
|
||||
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$suffix = Str::lower(Str::random(6));
|
||||
$slug = Str::limit($base . '-' . $suffix, 160, '');
|
||||
|
||||
if (! Artwork::where('slug', $slug)->exists()) {
|
||||
return $slug;
|
||||
}
|
||||
}
|
||||
|
||||
return Str::limit($base . '-' . Str::uuid()->toString(), 160, '');
|
||||
return Str::limit($base !== '' ? $base : 'artwork', 160, '');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user