X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/a81a56706e8be77586631f3619ad84df36c8d84e..refs/pull/474/head:/app/Services/ActivityService.php diff --git a/app/Services/ActivityService.php b/app/Services/ActivityService.php index 54e922667..2368ba10a 100644 --- a/app/Services/ActivityService.php +++ b/app/Services/ActivityService.php @@ -8,18 +8,18 @@ class ActivityService { protected $activity; protected $user; - protected $restrictionService; + protected $permissionService; /** * ActivityService constructor. * @param Activity $activity - * @param RestrictionService $restrictionService + * @param PermissionService $permissionService */ - public function __construct(Activity $activity, RestrictionService $restrictionService) + public function __construct(Activity $activity, PermissionService $permissionService) { $this->activity = $activity; - $this->restrictionService = $restrictionService; - $this->user = auth()->user(); + $this->permissionService = $permissionService; + $this->user = user(); } /** @@ -88,9 +88,9 @@ class ActivityService */ public function latest($count = 20, $page = 0) { - $activityList = $this->restrictionService + $activityList = $this->permissionService ->filterRestrictedEntityRelations($this->activity, 'activities', 'entity_id', 'entity_type') - ->orderBy('created_at', 'desc')->skip($count * $page)->take($count)->get(); + ->orderBy('created_at', 'desc')->with('user', 'entity')->skip($count * $page)->take($count)->get(); return $this->filterSimilar($activityList); } @@ -112,9 +112,9 @@ class ActivityService ->where('entity_id', '=', $entity->id); } - $activity = $this->restrictionService + $activity = $this->permissionService ->filterRestrictedEntityRelations($query, 'activities', 'entity_id', 'entity_type') - ->orderBy('created_at', 'desc')->skip($count * $page)->take($count)->get(); + ->orderBy('created_at', 'desc')->with(['entity', 'user.avatar'])->skip($count * $page)->take($count)->get(); return $this->filterSimilar($activity); } @@ -129,7 +129,7 @@ class ActivityService */ public function userActivity($user, $count = 20, $page = 0) { - $activityList = $this->restrictionService + $activityList = $this->permissionService ->filterRestrictedEntityRelations($this->activity, 'activities', 'entity_id', 'entity_type') ->orderBy('created_at', 'desc')->where('user_id', '=', $user->id)->skip($count * $page)->take($count)->get(); return $this->filterSimilar($activityList);