]> BookStack Code Mirror - bookstack/blobdiff - app/Services/ViewService.php
replace GPL diff lib with MIT lib
[bookstack] / app / Services / ViewService.php
index 849a164cf409995a596dd7113d34bebb47d50601..aac9831f74cac2ffee9c84c19f6e94e18934bb34 100644 (file)
@@ -50,7 +50,7 @@ class ViewService
      * Get the entities with the most views.
      * @param int $count
      * @param int $page
-     * @param bool|false $filterModel
+     * @param bool|false|array $filterModel
      */
     public function getPopular($count = 10, $page = 0, $filterModel = false)
     {
@@ -60,7 +60,11 @@ class ViewService
             ->groupBy('viewable_id', 'viewable_type')
             ->orderBy('view_count', 'desc');
 
-        if ($filterModel) $query->where('viewable_type', '=', get_class($filterModel));
+        if ($filterModel && is_array($filterModel)) {
+            $query->whereIn('viewable_type', $filterModel);
+        } else if ($filterModel) {
+            $query->where('viewable_type', '=', get_class($filterModel));
+        };
 
         return $query->with('viewable')->skip($skipCount)->take($count)->get()->pluck('viewable');
     }