Skip to content

astroshippers/notion-notification-channel

Repository files navigation

Installation

composer require astroshippers/notion-notification-channel

Usage

Inside eloquent model:

public function routeNotificationForNotion(): array
{
    return [
        'token'    => config('services.notion.token'),
        'database' => '8e12b788392e4367b0532c9abb519133',
    ];
}

Inside notification class:

use NotificationChannels\Notion\{NotionChannel, NotionDatabaseItem};
use NotificationChannels\Notion\Properties\{Checkbox, Email, MultiSelect, Number, RichText, Status, Title, URL};

public function via($notifiable)
{
    return [NotionChannel::class];
}

public function toNotion(User $notifiable): NotionDatabaseItem
{
    return NotionDatabaseItem::create()
        ->properties([
            'Name'          => Title::make('John Doe'),
            'Email'         => Email::make('[email protected]'),
            'SomeNumber'    => Number::make(12345),
            'Tags'          => MultiSelect::make(['blah', 'blah2', 'blah3']),
            'True or False' => Checkbox::make(false),
            'URL'           => URL::make('https://developers.notion.com/reference/property-value-object'),
            'Some Text'     => RichText::make([
                [
                    "type" => "text",
                    "text" => [
                        "content" => "Some more text with ",
                    ]
                ],
            ]),
        ]);
}