mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-01 05:51:52 +08:00
Check if parent is a chapter. If so, move into Book and assing page to chapter.
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user