X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/a3cf45cfb6078e014b84d10d80ca6f5242acd33f..refs/pull/2376/head:/app/Entities/Repos/BookshelfRepo.php diff --git a/app/Entities/Repos/BookshelfRepo.php b/app/Entities/Repos/BookshelfRepo.php index 03b54f009..49fb75f4c 100644 --- a/app/Entities/Repos/BookshelfRepo.php +++ b/app/Entities/Repos/BookshelfRepo.php @@ -28,8 +28,10 @@ class BookshelfRepo */ public function getAllPaginated(int $count = 20, string $sort = 'name', string $order = 'asc'): LengthAwarePaginator { - return Bookshelf::visible()->with('visibleBooks') - ->orderBy($sort, $order)->paginate($count); + return Bookshelf::visible() + ->with('visibleBooks') + ->orderBy($sort, $order) + ->paginate($count); } /** @@ -91,10 +93,14 @@ class BookshelfRepo /** * Create a new shelf in the system. */ - public function update(Bookshelf $shelf, array $input, array $bookIds): Bookshelf + public function update(Bookshelf $shelf, array $input, ?array $bookIds): Bookshelf { $this->baseRepo->update($shelf, $input); - $this->updateBooks($shelf, $bookIds); + + if (!is_null($bookIds)) { + $this->updateBooks($shelf, $bookIds); + } + return $shelf; } @@ -123,7 +129,7 @@ class BookshelfRepo * @throws ImageUploadException * @throws Exception */ - public function updateCoverImage(Bookshelf $shelf, UploadedFile $coverImage = null, bool $removeImage = false) + public function updateCoverImage(Bookshelf $shelf, ?UploadedFile $coverImage, bool $removeImage = false) { $this->baseRepo->updateCoverImage($shelf, $coverImage, $removeImage); } @@ -168,6 +174,7 @@ class BookshelfRepo public function destroy(Bookshelf $shelf) { $trashCan = new TrashCan(); - $trashCan->destroyShelf($shelf); + $trashCan->softDestroyShelf($shelf); + $trashCan->autoClearOld(); } }