X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/b8e2d75014c89c9e345c3f940ec8743bd158df67..refs/pull/3141/head:/app/Entities/Tools/SlugGenerator.php diff --git a/app/Entities/Tools/SlugGenerator.php b/app/Entities/Tools/SlugGenerator.php index 4501279f2..9fd9036ad 100644 --- a/app/Entities/Tools/SlugGenerator.php +++ b/app/Entities/Tools/SlugGenerator.php @@ -1,15 +1,17 @@ -slugInUse($slug, $model)) { $slug .= '-' . Str::random(3); } + return $slug; } @@ -26,15 +29,18 @@ class SlugGenerator protected function formatNameAsSlug(string $name): string { $slug = Str::slug($name); - if ($slug === "") { + if ($slug === '') { $slug = substr(md5(rand(1, 500)), 0, 5); } + return $slug; } /** * Check if a slug is already in-use for this * type of model within the same parent. + * + * @param Sluggable&Model $model */ protected function slugInUse(string $slug, Sluggable $model): bool {