site()->pages()->create(
'my-page',
'default',
['title' => 'A title']
);
It works fine. I also use this for a subpage:
page('my-page')->children()->create(
'subpage',
'article',
['title' => 'A title']
);
It works fine as well. Is there a way to use the same query for both types of pages, for both the root page and the subpage?
I tried this to create the root page, but it does not work by obvious reasons:
page('')->children()->create(
'my-page',
'article',
['title' => 'A title']
);
The reason for my question is that if I can use one type of query instead of two, I can remove 50% of my code. Also I can probably use a better approach for update as well.
Is there a single way to create both the root page and the subpage?
(I’m aware of that I need to have the root page, before creating the subpage).