+
+ /**
+ * Show the Restrictions view.
+ * @param $bookSlug
+ * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+ */
+ public function showRestrict($bookSlug)
+ {
+ $book = $this->entityRepo->getBySlug('book', $bookSlug);
+ $this->checkOwnablePermission('restrictions-manage', $book);
+ $roles = $this->userRepo->getRestrictableRoles();
+ return view('books/restrictions', [
+ 'book' => $book,
+ 'roles' => $roles
+ ]);
+ }
+
+ /**
+ * Set the restrictions for this book.
+ * @param $bookSlug
+ * @param $bookSlug
+ * @param Request $request
+ * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
+ */
+ public function restrict($bookSlug, Request $request)
+ {
+ $book = $this->entityRepo->getBySlug('book', $bookSlug);
+ $this->checkOwnablePermission('restrictions-manage', $book);
+ $this->entityRepo->updateEntityPermissionsFromRequest($request, $book);
+ session()->flash('success', trans('entities.books_permissions_updated'));
+ return redirect($book->getUrl());
+ }
+
+ /**
+ * Export a book as a PDF file.
+ * @param string $bookSlug
+ * @return mixed
+ */
+ public function exportPdf($bookSlug)
+ {
+ $book = $this->entityRepo->getBySlug('book', $bookSlug);
+ $pdfContent = $this->exportService->bookToPdf($book);
+ return response()->make($pdfContent, 200, [
+ 'Content-Type' => 'application/octet-stream',
+ 'Content-Disposition' => 'attachment; filename="' . $bookSlug . '.pdf'
+ ]);
+ }
+
+ /**
+ * Export a book as a contained HTML file.
+ * @param string $bookSlug
+ * @return mixed
+ */
+ public function exportHtml($bookSlug)
+ {
+ $book = $this->entityRepo->getBySlug('book', $bookSlug);
+ $htmlContent = $this->exportService->bookToContainedHtml($book);
+ return response()->make($htmlContent, 200, [
+ 'Content-Type' => 'application/octet-stream',
+ 'Content-Disposition' => 'attachment; filename="' . $bookSlug . '.html'
+ ]);
+ }
+
+ /**
+ * Export a book as a plain text file.
+ * @param $bookSlug
+ * @return mixed
+ */
+ public function exportPlainText($bookSlug)
+ {
+ $book = $this->entityRepo->getBySlug('book', $bookSlug);
+ $htmlContent = $this->exportService->bookToPlainText($book);
+ return response()->make($htmlContent, 200, [
+ 'Content-Type' => 'application/octet-stream',
+ 'Content-Disposition' => 'attachment; filename="' . $bookSlug . '.txt'
+ ]);
+ }