+
+ /**
+ * Show the view to copy a book.
+ *
+ * @throws NotFoundException
+ */
+ public function showCopy(string $bookSlug)
+ {
+ $book = $this->bookRepo->getBySlug($bookSlug);
+ $this->checkOwnablePermission('book-view', $book);
+
+ session()->flashInput(['name' => $book->name]);
+
+ return view('books.copy', [
+ 'book' => $book,
+ ]);
+ }
+
+ /**
+ * Create a copy of a book within the requested target destination.
+ *
+ * @throws NotFoundException
+ */
+ public function copy(Request $request, Cloner $cloner, string $bookSlug)
+ {
+ $book = $this->bookRepo->getBySlug($bookSlug);
+ $this->checkOwnablePermission('book-view', $book);
+ $this->checkPermission('book-create-all');
+
+ $newName = $request->get('name') ?: $book->name;
+ $bookCopy = $cloner->cloneBook($book, $newName);
+ $this->showSuccessNotification(trans('entities.books_copy_success'));
+
+ return redirect($bookCopy->getUrl());
+ }
+
+ /**
+ * Convert the chapter to a book.
+ */
+ public function convertToShelf(HierarchyTransformer $transformer, string $bookSlug)
+ {
+ $book = $this->bookRepo->getBySlug($bookSlug);
+ $this->checkOwnablePermission('book-update', $book);
+ $this->checkOwnablePermission('book-delete', $book);
+ $this->checkPermission('bookshelf-create-all');
+ $this->checkPermission('book-create-all');
+
+ $shelf = $transformer->transformBookToShelf($book);
+
+ return redirect($shelf->getUrl());
+ }