X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/b8c16b15a9f945b72d2ca4fe0c0172ba422199bc..refs/pull/2376/head:/app/Entities/Repos/BookshelfRepo.php diff --git a/app/Entities/Repos/BookshelfRepo.php b/app/Entities/Repos/BookshelfRepo.php index 25fa97dae..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; } @@ -168,6 +174,7 @@ class BookshelfRepo public function destroy(Bookshelf $shelf) { $trashCan = new TrashCan(); - $trashCan->destroyShelf($shelf); + $trashCan->softDestroyShelf($shelf); + $trashCan->autoClearOld(); } }