]> BookStack Code Mirror - bookstack/blobdiff - app/Actions/ViewService.php
Add base64 image support
[bookstack] / app / Actions / ViewService.php
index ec57cdb764b6e701a109c20a7ad9668048db2f94..f04384536ec8586a7a15153523b0196a1f3c3d95 100644 (file)
@@ -65,7 +65,7 @@ class ViewService
     {
         $skipCount = $count * $page;
         $query = $this->permissionService
-            ->filterRestrictedEntityRelations($this->view, 'views', 'viewable_id', 'viewable_type', $action)
+            ->filterRestrictedEntityRelations($this->view->newQuery(), 'views', 'viewable_id', 'viewable_type', $action)
             ->select('*', 'viewable_id', 'viewable_type', DB::raw('SUM(views) as view_count'))
             ->groupBy('viewable_id', 'viewable_type')
             ->orderBy('view_count', 'desc');
@@ -74,7 +74,12 @@ class ViewService
             $query->whereIn('viewable_type', $this->entityProvider->getMorphClasses($filterModels));
         }
 
-        return $query->with('viewable')->skip($skipCount)->take($count)->get()->pluck('viewable');
+        return $query->with('viewable')
+            ->skip($skipCount)
+            ->take($count)
+            ->get()
+            ->pluck('viewable')
+            ->filter();
     }
 
     /**