X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/c7a2d568bf693add30c8402d68d1f46f09a44c5b..refs/pull/3210/head:/app/Entities/Repos/BookRepo.php diff --git a/app/Entities/Repos/BookRepo.php b/app/Entities/Repos/BookRepo.php index 3fb924a89..7c4b280a8 100644 --- a/app/Entities/Repos/BookRepo.php +++ b/app/Entities/Repos/BookRepo.php @@ -1,8 +1,10 @@ -orderBy($sort, $order)->paginate($count); + return Book::visible()->with('cover')->orderBy($sort, $order)->paginate($count); } /** @@ -84,13 +85,14 @@ class BookRepo } /** - * Create a new book in the system + * Create a new book in the system. */ public function create(array $input): Book { $book = new Book(); $this->baseRepo->create($book, $input); - Activity::addForEntity($book, ActivityType::BOOK_CREATE); + Activity::add(ActivityType::BOOK_CREATE, $book); + return $book; } @@ -100,12 +102,14 @@ class BookRepo public function update(Book $book, array $input): Book { $this->baseRepo->update($book, $input); - Activity::addForEntity($book, ActivityType::BOOK_UPDATE); + Activity::add(ActivityType::BOOK_UPDATE, $book); + return $book; } /** * Update the given book's cover image, or clear it. + * * @throws ImageUploadException * @throws Exception */ @@ -114,23 +118,16 @@ class BookRepo $this->baseRepo->updateCoverImage($book, $coverImage, $removeImage); } - /** - * Update the permissions of a book. - */ - public function updatePermissions(Book $book, bool $restricted, Collection $permissions = null) - { - $this->baseRepo->updatePermissions($book, $restricted, $permissions); - } - /** * Remove a book from the system. + * * @throws Exception */ public function destroy(Book $book) { $trashCan = new TrashCan(); $trashCan->softDestroyBook($book); - Activity::addForEntity($book, ActivityType::BOOK_DELETE); + Activity::add(ActivityType::BOOK_DELETE, $book); $trashCan->autoClearOld(); }