Examples for Property-Handling

Page Properties

// Access properties from a specific page
$page = \Notion::pages()

// Returns all properties as collection

// Returns specific property by propertyKey

// Returns specific property content by propertyKey (returned type depends on the property-type)

// Returns specific property content by propertyKey (array of exact Notion API structure is returned)

// Returns array of propertyKeys (names/titles of properties)

// Return json-array of all properties

Page Property-Classes

There are several property classes available; see src/Entities/Properties.

$page = \Notion::pages()->find($pageId);

// Property MultiSelect
$multiSelectProperty = $page->getProperty($propertyKeyOfMultiSelect); // returns MultiSelect::class
$mutliSelectProperty->getNames(); // returns array of names. For example: ['vegan recipe', 'sweet', 'healthy']
$mutliSelectProperty->getColors(); // returns array of colors. For example: ['blue', 'yellow', 'green']
$multiSelectProperty->getItems(); // returns Collection of SelectItem::class
$multiSelectProperty->getItems()->first()->getName(); // returns name of specific SelectItem
$multiSelectProperty->getItems()->first()->getColor(); // returns color of specific SelectItem