+ $shelf = $this->entityRepo->getEntityBySlug('bookshelf', $slug);
+ $this->checkOwnablePermission('restrictions-manage', $shelf);
+
+ $updateCount = $this->entityRepo->copyBookshelfPermissions($shelf);
+ $this->showSuccessNotification( trans('entities.shelves_copy_permission_success', ['count' => $updateCount]));
+ return redirect($shelf->getUrl());
+ }
+
+ /**
+ * Common actions to run on bookshelf update.
+ * @param Bookshelf $shelf
+ * @param Request $request
+ * @throws \BookStack\Exceptions\ImageUploadException
+ */
+ protected function shelfUpdateActions(Bookshelf $shelf, Request $request)
+ {
+ // Update the books that the shelf references
+ $this->entityRepo->updateShelfBooks($shelf, $request->get('books', ''));
+
+ // Update the cover image if in request
+ if ($request->has('image')) {
+ $newImage = $request->file('image');
+ $this->imageRepo->destroyImage($shelf->cover);
+ $image = $this->imageRepo->saveNew($newImage, 'cover_shelf', $shelf->id, 512, 512, true);
+ $shelf->image_id = $image->id;
+ $shelf->save();
+ }