X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/37bf7f11e4361902ad92ceaf6bd15f1f85b76188..refs/pull/1688/head:/app/Actions/ViewService.php diff --git a/app/Actions/ViewService.php b/app/Actions/ViewService.php index 292784e86..b576483a0 100644 --- a/app/Actions/ViewService.php +++ b/app/Actions/ViewService.php @@ -3,6 +3,7 @@ use BookStack\Auth\Permissions\PermissionService; use BookStack\Entities\Entity; use BookStack\Entities\EntityProvider; +use DB; use Illuminate\Support\Collection; class ViewService @@ -13,8 +14,8 @@ class ViewService /** * ViewService constructor. - * @param \BookStack\Actions\View $view - * @param \BookStack\Auth\Permissions\PermissionService $permissionService + * @param View $view + * @param PermissionService $permissionService * @param EntityProvider $entityProvider */ public function __construct(View $view, PermissionService $permissionService, EntityProvider $entityProvider) @@ -26,7 +27,7 @@ class ViewService /** * Add a view to the given entity. - * @param Entity $entity + * @param \BookStack\Entities\Entity $entity * @return int */ public function add(Entity $entity) @@ -59,12 +60,12 @@ class ViewService * @param string $action - used for permission checking * @return Collection */ - public function getPopular(int $count = 10, int $page = 0, $filterModels = null, $action = 'view') + public function getPopular(int $count = 10, int $page = 0, $filterModels = null, string $action = 'view') { - // TODO - Standardise input filter $skipCount = $count * $page; - $query = $this->permissionService->filterRestrictedEntityRelations($this->view, 'views', 'viewable_id', 'viewable_type', $action) - ->select('*', 'viewable_id', 'viewable_type', \DB::raw('SUM(views) as view_count')) + $query = $this->permissionService + ->filterRestrictedEntityRelations($this->view, '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');