X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/ddb7f33868ea499ab8f48a7062f145e8c0fbe02f..refs/pull/2515/head:/app/Entities/Repos/BookRepo.php diff --git a/app/Entities/Repos/BookRepo.php b/app/Entities/Repos/BookRepo.php index 7fcc80fac..27d0b4075 100644 --- a/app/Entities/Repos/BookRepo.php +++ b/app/Entities/Repos/BookRepo.php @@ -1,14 +1,14 @@ orderBy($sort, $order)->paginate($count); + return Book::visible()->with('cover')->orderBy($sort, $order)->paginate($count); } /** @@ -91,6 +90,7 @@ class BookRepo { $book = new Book(); $this->baseRepo->create($book, $input); + Activity::addForEntity($book, ActivityType::BOOK_CREATE); return $book; } @@ -100,6 +100,7 @@ class BookRepo public function update(Book $book, array $input): Book { $this->baseRepo->update($book, $input); + Activity::addForEntity($book, ActivityType::BOOK_UPDATE); return $book; } @@ -108,27 +109,21 @@ class BookRepo * @throws ImageUploadException * @throws Exception */ - public function updateCoverImage(Book $book, UploadedFile $coverImage = null, bool $removeImage = false) + public function updateCoverImage(Book $book, ?UploadedFile $coverImage, bool $removeImage = false) { $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 NotifyException - * @throws BindingResolutionException + * @throws Exception */ public function destroy(Book $book) { $trashCan = new TrashCan(); - $trashCan->destroyBook($book); + $trashCan->softDestroyBook($book); + Activity::addForEntity($book, ActivityType::BOOK_DELETE); + + $trashCan->autoClearOld(); } }