Create page in PHP with Page Reference field

I use page::create to create new childs in PHP. However, I am wondering how the Code have to look when I want to create a entry for a pages field. In Yaml it’s saved like this:

Image:

- >
  products/test

How can this be done with PHP? I have no idea to be honest.

$page = Page::create([
  'slug'     => 'child1',
  'template' => 'product',
  'content' => [
    'title'  => 'Child 1',
    'image' => ?
  ]
]);

You would provide an array of page ids

$page = Page::create([
  'slug'     => 'child1',
  'template' => 'product',
  'content' => [
    'title'  => 'Child 1',
    'image' => ['products/test']
  ]
]);

Oh wow! So page::create(); check if it’s a array and turn this into the right yaml syntax? Can it be this easy (again) :slight_smile: