]> BookStack Code Mirror - bookstack/blobdiff - app/Repos/PageRepo.php
Update Ldap.php
[bookstack] / app / Repos / PageRepo.php
index 521cad07bc2611512d3b5ab08530641f4c0ccf22..e6d713f77c591f3451c38ff777d5060974946292 100644 (file)
@@ -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;
@@ -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)
     {