X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/f5f96f84e7061dc2356510760c200ccae415fee5..refs/pull/5591/head:/app/Entities/Queries/QueryPopular.php diff --git a/app/Entities/Queries/QueryPopular.php b/app/Entities/Queries/QueryPopular.php index 2b46ebfbc..065ae82ef 100644 --- a/app/Entities/Queries/QueryPopular.php +++ b/app/Entities/Queries/QueryPopular.php @@ -18,7 +18,7 @@ class QueryPopular ) { } - public function run(int $count, int $page, array $filterModels = null): Collection + public function run(int $count, int $page, array $filterModels): Collection { $query = $this->permissions ->restrictEntityRelationQuery(View::query(), 'views', 'viewable_id', 'viewable_type') @@ -26,7 +26,7 @@ class QueryPopular ->groupBy('viewable_id', 'viewable_type') ->orderBy('view_count', 'desc'); - if ($filterModels) { + if (!empty($filterModels)) { $query->whereIn('viewable_type', $this->entityProvider->getMorphClasses($filterModels)); } @@ -35,7 +35,7 @@ class QueryPopular ->take($count) ->get(); - $this->listLoader->loadIntoRelations($views->all(), 'viewable', false); + $this->listLoader->loadIntoRelations($views->all(), 'viewable', true); return $views->pluck('viewable')->filter(); }