X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/a6c6c6e300c60e4dd2b02501c827571da1adf1be..refs/pull/255/head:/app/Repos/PageRepo.php diff --git a/app/Repos/PageRepo.php b/app/Repos/PageRepo.php index 8cd5c35a9..e6d713f77 100644 --- a/app/Repos/PageRepo.php +++ b/app/Repos/PageRepo.php @@ -5,7 +5,7 @@ use BookStack\Book; use BookStack\Chapter; use BookStack\Entity; use BookStack\Exceptions\NotFoundException; -use BookStack\Services\FileService; +use BookStack\Services\AttachmentService; use Carbon\Carbon; use DOMDocument; use DOMXPath; @@ -60,7 +60,7 @@ class PageRepo extends EntityRepo * Get a page identified by the given slug. * @param $slug * @param $bookId - * @return mixed + * @return Page * @throws NotFoundException */ public function getBySlug($slug, $bookId) @@ -614,8 +614,7 @@ class PageRepo 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); } @@ -636,9 +635,9 @@ class PageRepo extends EntityRepo $this->permissionService->deleteJointPermissionsForEntity($page); // Delete AttachedFiles - $fileService = app(FileService::class); - foreach ($page->files as $file) { - $fileService->deleteFile($file); + $attachmentService = app(AttachmentService::class); + foreach ($page->attachments as $attachment) { + $attachmentService->deleteFile($attachment); } $page->delete(); @@ -647,6 +646,7 @@ class PageRepo extends EntityRepo /** * Get the latest pages added to the system. * @param $count + * @return mixed */ public function getRecentlyCreatedPaginated($count = 20) { @@ -656,6 +656,7 @@ class PageRepo extends EntityRepo /** * Get the latest pages added to the system. * @param $count + * @return mixed */ public function getRecentlyUpdatedPaginated($count = 20) {