]> BookStack Code Mirror - bookstack/blobdiff - app/Uploads/ImageRepo.php
Updated attachment links to have dropdown for open type
[bookstack] / app / Uploads / ImageRepo.php
index 67297f3087ee34fb856985cce586435fdee3a3df..bfe4b597739a8e26f423c4f5f04d9d78f0db805f 100644 (file)
@@ -17,7 +17,8 @@ class ImageRepo
     /**
      * ImageRepo constructor.
      */
-    public function __construct(ImageService $imageService, PermissionService $permissionService) {
+    public function __construct(ImageService $imageService, PermissionService $permissionService)
+    {
         $this->imageService = $imageService;
         $this->restrictionService = $permissionService;
     }
@@ -102,7 +103,10 @@ class ImageRepo
                 if ($filterType === 'page') {
                     $query->where('uploaded_to', '=', $contextPage->id);
                 } elseif ($filterType === 'book') {
-                    $validPageIds = $contextPage->book->pages()->visible()->get(['id'])->pluck('id')->toArray();
+                    $validPageIds = $contextPage->book->pages()
+                        ->scopes('visible')
+                        ->pluck('id')
+                        ->toArray();
                     $query->whereIn('uploaded_to', $validPageIds);
                 }
             };
@@ -235,7 +239,7 @@ class ImageRepo
             ->get(['id', 'name', 'slug', 'book_id']);
 
         foreach ($pages as $page) {
-            $page->url = $page->getUrl();
+            $page->setAttribute('url', $page->getUrl());
         }
 
         return $pages->all();