Skip to content

Commit ed6ad32

Browse files
authored
Merge branch 'dev' into l10-compatibility
2 parents 44294ba + 80f38df commit ed6ad32

28 files changed

+2960
-1673
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ jobs:
1212
php:
1313
- '8.1'
1414
- '8.0'
15-
- '7.4'
1615
laravel:
1716
- '8.*'
1817
testbench:
@@ -45,4 +44,4 @@ jobs:
4544
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
4645
4746
- name: Execute tests
48-
run: vendor/bin/phpunit tests
47+
run: vendor/bin/pest tests

README.md

Lines changed: 44 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
<h1 align="center"> Laravel Notion API</h1>
2-
<h2 align="center"> Effortless Notion integrations with Laravel</h2>
1+
<h1 align="center"> Notion for Laravel</h1>
32

4-
<p align="center">
5-
<img src="https://5amco.de/images/5am.png" width="200" height="200">
6-
</p>
3+
<img src="https://banners.beyondco.de/Notion%20for%20Laravel.png?theme=light&packageManager=composer+require&packageName=fiveam-code%2Flaravel-notion-api&pattern=architect&style=style_1&description=Effortless+Notion+integrations+with+Laravel&md=1&showWatermark=1&fontSize=100px&images=https%3A%2F%2Flaravel.com%2Fimg%2Flogomark.min.svg">
74

85
[![Latest Version on Packagist](https://img.shields.io/packagist/v/fiveam-code/laravel-notion-api.svg?style=flat-square)](https://packagist.org/packages/fiveam-code/laravel-notion-api)
96
[![Total Downloads](https://img.shields.io/packagist/dt/fiveam-code/laravel-notion-api.svg?style=flat-square)](https://packagist.org/packages/fiveam-code/laravel-notion-api)
@@ -12,52 +9,58 @@
129

1310
This package provides a simple and crisp way to access the Notion API endpoints, query data and update existing entries.
1411

12+
1513
## Installation
1614

17-
You can install the package via composer:
15+
1. You can install the package via composer:
1816

19-
```bash
20-
composer require fiveam-code/laravel-notion-api
21-
```
17+
```bash
18+
composer require fiveam-code/laravel-notion-api
19+
```
2220

23-
### Authorization
2421

25-
The Notion API requires an access token and a Notion integration, [the Notion documentation](https://developers.notion.com/docs/getting-started#before-we-begin) explains how this works. It's important to grant access to the integration within your Notion account to enable the API access.
22+
2. Get your Notion API access token like explained in [their documentation](https://developers.notion.com/). It's also
23+
important to grant access to the integration within your Notion pages, which is described in the developer documentation at Notion as well.
2624
27-
Add your Notion API token to your `.env` file:
25+
3. For internal Integrations, please add a new entry to your `.env` like the following:
26+
27+
```bash
28+
NOTION_API_TOKEN="$YOUR_ACCESS_TOKEN"
29+
```
30+
4. Now you can easily access Notion:
31+
```php
32+
use \Notion;
33+
34+
Notion::databases()->find($databaseId);
35+
```
36+
37+
That's it.
2838

29-
```
30-
NOTION_API_TOKEN="$YOUR_ACCESS_TOKEN"
31-
```
3239

3340
## Usage
3441

35-
Head over to the [Documentation](https://5amco.de/docs) of this package.
42+
Head over to the [Documentation](https://notionforlaravel.com) of this package.
3643

37-
### 🔥 Code Examples to jumpstart your Notion API Project
44+
### 🔥 Code Examples to jumpstart your next Notion API Project
3845

39-
#### Basic Setup (+ example)
46+
#### Fetch a Notion Database (through a Facade)
4047
```php
41-
use FiveamCode\LaravelNotionApi\Notion;
48+
use \Notion;
4249
43-
# Access through Facade (token has to be set in .env)
44-
\Notion::databases()->find($databaseId);
45-
46-
# Custom instantiation (necessary if you want to access more than one NotionApi integration)
47-
$notion = new Notion($apiToken, $apiVersion); // version-default is 'v1'
48-
$notion->databases()->find($databaseId);
50+
Notion::databases()
51+
->find("a7e5e47d-23ca-463b-9750-eb07ca7115e4");
4952
```
5053

51-
#### Fetch Page Information
54+
#### Fetch a Notion Page
5255
```php
53-
// Returns a specific page
54-
\Notion::pages()->find($yourPageId);
56+
Notion::pages()
57+
->find("e7e5e47d-23ca-463b-9750-eb07ca7115e4");
5558
```
5659

5760
#### Search
5861
```php
5962
// Returns a collection pages and databases of your workspace (included in your integration-token)
60-
\Notion::search($searchText)
63+
Notion::search("My Notion Search")
6164
->query()
6265
->asCollection();
6366
```
@@ -69,18 +72,14 @@ $notion->databases()->find($databaseId);
6972
$sortings = new Collection();
7073
$filters = new Collection();
7174
72-
$sortings
73-
->add(Sorting::propertySort('Ordered', 'ascending'));
74-
$sortings
75-
->add(Sorting::timestampSort('created_time', 'ascending'));
75+
$sortings->add(Sorting::propertySort('Ordered', 'ascending'));
76+
$sortings->add(Sorting::timestampSort('created_time', 'ascending'));
7677
77-
$filters
78-
->add(Filter::textFilter('title', ['contains' => 'new']));
78+
$filters->add(Filter::textFilter('title', ['contains' => 'new']));
7979
// or
80-
$filters
81-
->add(Filter::rawFilter('Tags', ['multi_select' => ['contains' => 'great']]));
80+
$filters->add(Filter::rawFilter('Tags', ['multi_select' => ['contains' => 'great']]));
8281
83-
\Notion::database($yourDatabaseId)
82+
Notion::database("a7e5e47d-23ca-463b-9750-eb07ca7115e4")
8483
->filterBy($filters) // filters are optional
8584
->sortBy($sortings) // sorts are optional
8685
->limit(5) // limit is optional
@@ -89,10 +88,10 @@ $filters
8988
```
9089
9190
92-
### Testing
91+
### Testing (pestphp)
9392
9493
```bash
95-
vendor/bin/phpunit tests
94+
vendor/bin/pest tests
9695
```
9796
9897
## Support
@@ -107,19 +106,16 @@ Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
107106
108107
If you discover any security related issues, please email hello@dianaweb.dev instead of using the issue tracker.
109108
110-
## Used By
111-
112-
- Julien Nahum created [notionforms.io](https://notionforms.io) with [laravel-notion-api](https://github.com/5am-code/laravel-notion-api), which allows you to easily create custom forms, based on your selected database within notion.
113-
- [GitHub Notion Sync](https://githubnotionsync.com/), a service by [Beyond Code](https://beyondco.de) to sync the issues of multiple GitHub repositories into a Notion database
114-
- [Notion Invoice](https://notioninvoice.com/), the first premium invoicing solution for freelancers and businesses that use Notion. Create beautiful PDF invoices from your Notion data.
115-
116-
Using this package in your project? Open a PR to add it in this section!
117-
118109
## Credits
119110
120111
- [Diana Scharf](https://github.com/mechelon)
121112
- [Johannes Güntner](https://github.com/johguentner)
122113
114+
115+
<p align="center">
116+
<img src="https://5amco.de/images/5am.png" width="200" height="200">
117+
</p>
118+
123119
## License
124120
125121
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

composer.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@
2525
}
2626
],
2727
"require": {
28-
"php": "^7.4|^8.0",
28+
"php": "^8.0",
2929
"guzzlehttp/guzzle": "^7.0.1",
3030
"illuminate/support": "^8.0|^9.0|^10.0"
3131
},
3232
"require-dev": {
3333
"orchestra/testbench": "^6.0|^8.0",
34+
"pestphp/pest": "^1.22",
35+
"pestphp/pest-plugin-laravel": "^1.3",
3436
"phpunit/phpunit": "^9.0"
3537
},
3638
"autoload": {
@@ -46,8 +48,8 @@
4648
}
4749
},
4850
"scripts": {
49-
"test": "vendor/bin/phpunit",
50-
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
51+
"test": "vendor/bin/pest",
52+
"test-coverage": "vendor/bin/pest --coverage-html coverage"
5153
},
5254
"config": {
5355
"sort-packages": true

0 commit comments

Comments
 (0)