Page Creation Examples

Creating Pages in Notion, with properties is really easy:
Just create a Page object and set specific properties. First parameter is always your $property_key. The $property_key is your given title of the property within your table in notion.
Always make sure the title of the properties match exactly with your database.

✨ Below a summary of how to set all properties within a page.

Page Creation - In Database

$page = new Page();

# property: title
$page->setTitle("Name", "I was created by you");

# property: multi_select
$page->setMultiSelect("Tags", ["awesome"]);

# property: select
$page->setSelect("Created from", "Laravel");

# property: text
$page->setText("Comment", "Isn't this awesome?");

# property: checkbox
$page->setCheckbox("Is this great?", true);

# property: relation
$page->setRelation("Connected Pages of other Notion-DB", [$id_of_other_notion_database_page, $id_of_other_notion_database_page2]);

# property: people
$page->setPeople("Responsible People", [$user_id_of_connected_user, $user_id_of_connected_user2]);

# property: url
$page->setUrl("Website", "https://5amco.de");

# property: email
$page->setEmail("Contact E-Mail", "you.are.awesome@5amco.de");

# property: number
$page->setNumber("Invoice Sum", 500);

# property: phone_number
$page->setPhoneNumber("Contact Number", "+49 123456789");

Notion::pages()->createInDatabase($databaseId, $page);

Page Creation - Alternative way of settings properties

If you don't like to set the properties with a specific method in page, you can always use a generic method and instantiate the properties with a static method.
Just make sure you add the property-class to your imports.

use FiveamCode\LaravelNotionApi\Entities\Properties\Title;

$page = new Page();

# property: title
$page->set("Name", Title::value("I was created by you"));

# [...] Basically the same as in the above example.
Notion::pages()->createInDatabase($databaseId, $page);