+
+ /**
+ * Show the Restrictions view.
+ * @param $bookSlug
+ * @param $chapterSlug
+ * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+ */
+ public function showRestrict($bookSlug, $chapterSlug)
+ {
+ $book = $this->bookRepo->getBySlug($bookSlug);
+ $chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id);
+ $this->checkOwnablePermission('restrictions-manage', $chapter);
+ $roles = $this->userRepo->getRestrictableRoles();
+ return view('chapters/restrictions', [
+ 'chapter' => $chapter,
+ 'roles' => $roles
+ ]);
+ }
+
+ /**
+ * Set the restrictions for this chapter.
+ * @param $bookSlug
+ * @param $chapterSlug
+ * @param Request $request
+ * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
+ */
+ public function restrict($bookSlug, $chapterSlug, Request $request)
+ {
+ $book = $this->bookRepo->getBySlug($bookSlug);
+ $chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id);
+ $this->checkOwnablePermission('restrictions-manage', $chapter);
+ $this->chapterRepo->updateRestrictionsFromRequest($request, $chapter);
+ session()->flash('success', 'Page Restrictions Updated');
+ return redirect($chapter->getUrl());
+ }