X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/c157dc3490c39aa236e22714019a649ebeb11f13..refs/pull/3333/head:/app/Entities/Repos/BookRepo.php diff --git a/app/Entities/Repos/BookRepo.php b/app/Entities/Repos/BookRepo.php index c2a613f71..7c4b280a8 100644 --- a/app/Entities/Repos/BookRepo.php +++ b/app/Entities/Repos/BookRepo.php @@ -1,30 +1,28 @@ -orderBy($sort, $order)->paginate($count); + return Book::visible()->with('cover')->orderBy($sort, $order)->paginate($count); } /** @@ -87,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::add($book, ActivityType::BOOK_CREATE, $book->id); + Activity::add(ActivityType::BOOK_CREATE, $book); + return $book; } @@ -103,12 +102,14 @@ class BookRepo public function update(Book $book, array $input): Book { $this->baseRepo->update($book, $input); - Activity::add($book, ActivityType::BOOK_UPDATE, $book->id); + Activity::add(ActivityType::BOOK_UPDATE, $book); + return $book; } /** * Update the given book's cover image, or clear it. + * * @throws ImageUploadException * @throws Exception */ @@ -117,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::add($book, ActivityType::BOOK_DELETE, $book->id); + Activity::add(ActivityType::BOOK_DELETE, $book); $trashCan->autoClearOld(); }