use BookStack\Auth\Permissions\PermissionService;
use BookStack\Auth\User;
+use BookStack\Entities\Models\Book;
use BookStack\Entities\Models\Chapter;
use BookStack\Entities\Models\Entity;
use BookStack\Entities\Models\Page;
*/
public function entityActivity(Entity $entity, int $count = 20, int $page = 1): array
{
- /** @var [string => int[]] $queryIds */
+ /** @var array<string, int[]> $queryIds */
$queryIds = [$entity->getMorphClass() => [$entity->id]];
- if ($entity->isA('book')) {
- $queryIds[(new Chapter())->getMorphClass()] = $entity->chapters()->visible()->pluck('id');
+ if ($entity instanceof Book) {
+ $queryIds[(new Chapter())->getMorphClass()] = $entity->chapters()->scopes('visible')->pluck('id');
}
- if ($entity->isA('book') || $entity->isA('chapter')) {
- $queryIds[(new Page())->getMorphClass()] = $entity->pages()->visible()->pluck('id');
+ if ($entity instanceof Book || $entity instanceof Chapter) {
+ $queryIds[(new Page())->getMorphClass()] = $entity->pages()->scopes('visible')->pluck('id');
}
$query = $this->activity->newQuery();
}
/**
- * Get latest activity for a user, Filtering out similar items.
+ * Get the latest activity for a user, Filtering out similar items.
*/
public function userActivity(User $user, int $count = 20, int $page = 0): array
{