X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/c7a2d568bf693add30c8402d68d1f46f09a44c5b..refs/pull/2791/head:/app/Http/Controllers/ChapterController.php diff --git a/app/Http/Controllers/ChapterController.php b/app/Http/Controllers/ChapterController.php index 7fc92a8cf..d65b43cc1 100644 --- a/app/Http/Controllers/ChapterController.php +++ b/app/Http/Controllers/ChapterController.php @@ -1,14 +1,16 @@ book))->getTree(); $pages = $chapter->getVisiblePages(); - Views::add($chapter); + $nextPreviousLocator = new NextPreviousContentLocator($chapter, $sidebarTree); + View::incrementFor($chapter); $this->setPageTitle($chapter->getShortName()); return view('chapters.show', [ @@ -71,7 +74,9 @@ class ChapterController extends Controller 'chapter' => $chapter, 'current' => $chapter, 'sidebarTree' => $sidebarTree, - 'pages' => $pages + 'pages' => $pages, + 'next' => $nextPreviousLocator->getNext(), + 'previous' => $nextPreviousLocator->getPrevious(), ]); } @@ -190,14 +195,12 @@ class ChapterController extends Controller * Set the restrictions for this chapter. * @throws NotFoundException */ - public function permissions(Request $request, string $bookSlug, string $chapterSlug) + public function permissions(Request $request, PermissionsUpdater $permissionsUpdater, string $bookSlug, string $chapterSlug) { $chapter = $this->chapterRepo->getBySlug($bookSlug, $chapterSlug); $this->checkOwnablePermission('restrictions-manage', $chapter); - $restricted = $request->get('restricted') === 'true'; - $permissions = $request->filled('restrictions') ? collect($request->get('restrictions')) : null; - $this->chapterRepo->updatePermissions($chapter, $restricted, $permissions); + $permissionsUpdater->updateFromPermissionsForm($chapter, $request); $this->showSuccessNotification(trans('entities.chapters_permissions_success')); return redirect($chapter->getUrl());