- /**
- * Updates pages restrictions from a request
- * @param $request
- * @param $chapter
- */
- public function updateRestrictionsFromRequest($request, $chapter)
- {
- // TODO - extract into shared repo
- $chapter->restricted = $request->has('restricted') && $request->get('restricted') === 'true';
- $chapter->restrictions()->delete();
- if ($request->has('restrictions')) {
- foreach($request->get('restrictions') as $roleId => $restrictions) {
- foreach ($restrictions as $action => $value) {
- $chapter->restrictions()->create([
- 'role_id' => $roleId,
- 'action' => strtolower($action)
- ]);
- }
- }
+ // Update permissions if applicable
+ if ($rebuildPermissions) {
+ $chapter->load('book');
+ $this->permissionService->buildJointPermissionsForEntity($chapter->book);