3 namespace BookStack\Auth\Queries;
5 use BookStack\Auth\User;
6 use BookStack\Entities\Models\Book;
7 use BookStack\Entities\Models\Bookshelf;
8 use BookStack\Entities\Models\Chapter;
9 use BookStack\Entities\Models\Page;
12 * Get asset created counts for the given user.
14 class UserContentCounts
17 * @return array{pages: int, chapters: int, books: int, shelves: int}
19 public function run(User $user): array
21 $createdBy = ['created_by' => $user->id];
24 'pages' => Page::visible()->where($createdBy)->count(),
25 'chapters' => Chapter::visible()->where($createdBy)->count(),
26 'books' => Book::visible()->where($createdBy)->count(),
27 'shelves' => Bookshelf::visible()->where($createdBy)->count(),