Check if parent is a chapter. If so, move into Book and assing page to chapter.
This commit is contained in:
parent
d7557befe2
commit
4daeb9daa6
|
@ -306,6 +306,13 @@ class PageRepo
|
||||||
throw new PermissionsException('User does not have permission to create a page within the new parent');
|
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->changeBook($parent instanceof Book ? $parent->id : $parent->book->id);
|
||||||
$page->rebuildPermissions();
|
$page->rebuildPermissions();
|
||||||
return $parent;
|
return $parent;
|
||||||
|
|
Loading…
Reference in New Issue