+ if (is_null($newParentBook)) {
+ $this->showErrorNotification(trans('errors.selected_book_not_found'));
+
+ return redirect()->back();
+ }
+
+ $this->checkOwnablePermission('chapter-create', $newParentBook);
+
+ $newName = $request->get('name') ?: $chapter->name;
+ $chapterCopy = $cloner->cloneChapter($chapter, $newParentBook, $newName);
+ $this->showSuccessNotification(trans('entities.chapters_copy_success'));
+
+ return redirect($chapterCopy->getUrl());
+ }
+
+ /**
+ * Convert the chapter to a book.
+ */
+ public function convertToBook(HierarchyTransformer $transformer, string $bookSlug, string $chapterSlug)
+ {
+ $chapter = $this->chapterRepo->getBySlug($bookSlug, $chapterSlug);
+ $this->checkOwnablePermission('chapter-update', $chapter);
+ $this->checkOwnablePermission('chapter-delete', $chapter);
+ $this->checkPermission('book-create-all');
+
+ $book = $transformer->transformChapterToBook($chapter);
+
+ return redirect($book->getUrl());