+ }
+
+ /**
+ * 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.
+ * @throws NotFoundException
+ */
+ public function showDelete(string $bookSlug, string $chapterSlug)
+ {
+ $chapter = $this->chapterRepo->getBySlug($bookSlug, $chapterSlug);
+ $this->checkOwnablePermission('chapter-delete', $chapter);
+
+ $this->setPageTitle(trans('entities.chapters_delete_named', ['chapterName' => $chapter->getShortName()]));
+ return view('chapters.delete', ['book' => $chapter->book, 'chapter' => $chapter, 'current' => $chapter]);
+ }
+
+ /**
+ * Remove the specified chapter from storage.
+ * @throws NotFoundException
+ * @throws Throwable
+ */
+ public function destroy(string $bookSlug, string $chapterSlug)
+ {
+ $chapter = $this->chapterRepo->getBySlug($bookSlug, $chapterSlug);
+ $this->checkOwnablePermission('chapter-delete', $chapter);
+
+ $this->chapterRepo->destroy($chapter);