foreach ($entities as $entity) {
if ($entity->chapter_id === 0 || $entity->chapter_id === '0') continue;
$parentKey = 'BookStack\\Chapter:' . $entity->chapter_id;
+ if (!isset($parents[$parentKey])) {
+ $tree[] = $entity;
+ continue;
+ }
$chapter = $parents[$parentKey];
$chapter->pages->push($entity);
}
/**
* Alias method to update the book jointPermissions in the PermissionService.
- * @param Collection $collection collection on entities
+ * @param Book $book
*/
- public function buildJointPermissions(Collection $collection)
+ public function buildJointPermissionsForBook(Book $book)
{
- $this->permissionService->buildJointPermissionsForEntities($collection);
+ $this->permissionService->buildJointPermissionsForEntity($book);
}
/**
if ($chapter) $page->chapter_id = $chapter->id;
$book->pages()->save($page);
+ $page = $this->page->find($page->id);
$this->permissionService->buildJointPermissionsForEntity($page);
return $page;
}