- /**
- * Update the given shelf cover image, or clear it.
- * @throws ImageUploadException
- * @throws Exception
- */
- public function updateCoverImage(Bookshelf $shelf, UploadedFile $coverImage = null, bool $removeImage = false)
- {
- $this->baseRepo->updateCoverImage($shelf, $coverImage, $removeImage);
- }
-
- /**
- * Update the permissions of a bookshelf.
- */
- public function updatePermissions(Bookshelf $shelf, bool $restricted, Collection $permissions = null)
- {
- $this->baseRepo->updatePermissions($shelf, $restricted, $permissions);
- }
-
- /**
- * Copy down the permissions of the given shelf to all child books.
- */
- public function copyDownPermissions(Bookshelf $shelf): int
- {
- $shelfPermissions = $shelf->permissions()->get(['role_id', 'action'])->toArray();
- $shelfBooks = $shelf->books()->get();
- $updatedBookCount = 0;
-
- /** @var Book $book */
- foreach ($shelfBooks as $book) {
- if (!userCan('restrictions-manage', $book)) {
- continue;
- }
- $book->permissions()->delete();
- $book->restricted = $shelf->restricted;
- $book->permissions()->createMany($shelfPermissions);
- $book->save();
- $book->rebuildPermissions();
- $updatedBookCount++;
- }
-
- return $updatedBookCount;
- }
-