Check if parent is a chapter. If so, move into Book and assing page to chapter.

This commit is contained in:
jakob 2019-10-28 15:33:28 +01:00
parent d7557befe2
commit 4daeb9daa6

View File

@ -306,6 +306,13 @@ class PageRepo
throw new PermissionsException('User does not have permission to create a page within the new parent');
}
if ($parent instanceof Chapter) {
$parentChapter = $parent;
$parent = $parent->book;
$page->chapter_id = $parentChapter->id;
$page->save();
}
$page->changeBook($parent instanceof Book ? $parent->id : $parent->book->id);
$page->rebuildPermissions();
return $parent;