+ * Display the specified chapter.
+ */
+ public function show(string $bookSlug, string $chapterSlug)
+ {
+ $chapter = $this->chapterRepo->getBySlug($bookSlug, $chapterSlug);
+ $this->checkOwnablePermission('chapter-view', $chapter);
+
+ $sidebarTree = (new BookContents($chapter->book))->getTree();
+ $pages = $chapter->getVisiblePages();
+ $nextPreviousLocator = new NextPreviousContentLocator($chapter, $sidebarTree);
+ View::incrementFor($chapter);
+
+ $this->setPageTitle($chapter->getShortName());
+
+ return view('chapters.show', [
+ 'book' => $chapter->book,
+ 'chapter' => $chapter,
+ 'current' => $chapter,
+ 'sidebarTree' => $sidebarTree,
+ 'pages' => $pages,
+ 'next' => $nextPreviousLocator->getNext(),
+ 'previous' => $nextPreviousLocator->getPrevious(),
+ ]);
+ }
+
+ /**
+ * Show the form for editing the specified chapter.
+ */
+ public function edit(string $bookSlug, string $chapterSlug)
+ {
+ $chapter = $this->chapterRepo->getBySlug($bookSlug, $chapterSlug);
+ $this->checkOwnablePermission('chapter-update', $chapter);
+
+ $this->setPageTitle(trans('entities.chapters_edit_named', ['chapterName' => $chapter->getShortName()]));
+
+ return view('chapters.edit', ['book' => $chapter->book, 'chapter' => $chapter, 'current' => $chapter]);
+ }
+
+ /**
+ * Update the specified chapter in storage.
+ *
+ * @throws NotFoundException
+ */
+ public function update(Request $request, string $bookSlug, string $chapterSlug)
+ {
+ $chapter = $this->chapterRepo->getBySlug($bookSlug, $chapterSlug);
+ $this->checkOwnablePermission('chapter-update', $chapter);
+
+ $this->chapterRepo->update($chapter, $request->all());
+
+ return redirect($chapter->getUrl());
+ }
+
+ /**
+ * Shows the page to confirm deletion of this chapter.