]> BookStack Code Mirror - bookstack/blobdiff - app/Repos/ChapterRepo.php
Merge branch 'master' into translations
[bookstack] / app / Repos / ChapterRepo.php
index 96f5b2d1ea75d9c47858988b77d4489f3351be11..4106f93ee32e27ee7f3bfde0b759b11c02014a08 100644 (file)
@@ -69,7 +69,7 @@ class ChapterRepo extends EntityRepo
     public function getBySlug($slug, $bookId)
     {
         $chapter = $this->chapterQuery()->where('slug', '=', $slug)->where('book_id', '=', $bookId)->first();
-        if ($chapter === null) throw new NotFoundException('Chapter not found');
+        if ($chapter === null) throw new NotFoundException(trans('errors.chapter_not_found'));
         return $chapter;
     }
 
@@ -150,8 +150,7 @@ class ChapterRepo extends EntityRepo
      */
     public function findSuitableSlug($name, $bookId, $currentId = false)
     {
-        $slug = Str::slug($name);
-        if ($slug === "") $slug = substr(md5(rand(1, 500)), 0, 5);
+        $slug = $this->nameToSlug($name);
         while ($this->doesSlugExist($slug, $bookId, $currentId)) {
             $slug .= '-' . substr(md5(rand(1, 500)), 0, 3);
         }