Prefill new pages with book's default template

This commit is contained in:
Lennert Daniels 2022-12-02 18:42:58 +01:00
parent 1dbc3588cf
commit 99ae759eff
2 changed files with 6 additions and 1 deletions

View File

@ -148,6 +148,12 @@ class PageRepo
$page->book_id = $parent->id;
}
if ($page->book->defaultTemplate) {
$page->forceFill([
'html' => $page->book->defaultTemplate->html,
]);
}
$page->save();
$page->refresh()->rebuildPermissions();

View File

@ -74,7 +74,6 @@ class PageController extends Controller
$page = $this->pageRepo->getNewDraftPage($parent);
$this->pageRepo->publishDraft($page, [
'name' => $request->get('name'),
'html' => '',
]);
return redirect($page->getUrl('/edit'));