]> BookStack Code Mirror - bookstack/blobdiff - app/Actions/ActivityService.php
Update maintenance.php
[bookstack] / app / Actions / ActivityService.php
index 7b1046d220d34e14b0393420f80868229db1d284..f4f82a6f4dfbbac6b63c2fb42a15fad0631f77e9 100644 (file)
@@ -1,6 +1,5 @@
 <?php namespace BookStack\Actions;
 
-use BookStack\Actions\Activity;
 use BookStack\Auth\Permissions\PermissionService;
 use BookStack\Entities\Entity;
 use Session;
@@ -104,18 +103,22 @@ class ActivityService
      * @param int $page
      * @return array
      */
-    public function entityActivity($entity, $count = 20, $page = 0)
+    public function entityActivity($entity, $count = 20, $page = 1)
     {
         if ($entity->isA('book')) {
             $query = $this->activity->where('book_id', '=', $entity->id);
         } else {
-            $query = $this->activity->where('entity_type', '=', get_class($entity))
+            $query = $this->activity->where('entity_type', '=', $entity->getMorphClass())
                 ->where('entity_id', '=', $entity->id);
         }
         
         $activity = $this->permissionService
             ->filterRestrictedEntityRelations($query, 'activities', 'entity_id', 'entity_type')
-            ->orderBy('created_at', 'desc')->with(['entity', 'user.avatar'])->skip($count * $page)->take($count)->get();
+            ->orderBy('created_at', 'desc')
+            ->with(['entity', 'user.avatar'])
+            ->skip($count * ($page - 1))
+            ->take($count)
+            ->get();
 
         return $this->filterSimilar($activity);
     }