Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 77bab1c

Browse files
Merge pull request #12 from 5am-code/dev
Dev
2 parents 8127582 + df4433e commit 77bab1c

File tree

75 files changed

+4136
-747
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+4136
-747
lines changed

‎.github/workflows/main.yml‎

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,46 @@
1-
name: run-tests
1+
name: Run tests
22

3-
on:
4-
push:
5-
branches: [master]
6-
pull_request:
7-
branches: [master]
3+
on: ['push', 'workflow_dispatch']
84

95
jobs:
10-
test:
11-
runs-on: ${{ matrix.os }}
12-
strategy:
13-
fail-fast: true
14-
matrix:
15-
os: [ubuntu-latest, windows-latest]
16-
php: [7.4, 8.0]
17-
laravel: [8.*]
18-
stability: [prefer-lowest, prefer-stable]
19-
include:
20-
- laravel: 8.*
21-
testbench: ^6.6
22-
23-
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
24-
25-
steps:
26-
- name: Checkout code
27-
uses: actions/checkout@v2
28-
29-
- name: Setup PHP
30-
uses: shivammathur/setup-php@v2
31-
with:
32-
php-version: ${{ matrix.php }}
33-
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
34-
coverage: none
35-
36-
- name: Setup problem matchers
37-
run: |
38-
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
39-
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
40-
- name: Install dependencies
41-
run: |
42-
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
43-
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
44-
- name: Execute tests
45-
run: vendor/bin/phpunit
6+
php-tests:
7+
runs-on: ubuntu-latest
8+
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
php:
13+
- '8.0'
14+
laravel:
15+
- '8.*'
16+
testbench:
17+
- '6.*'
18+
dependency-version:
19+
- 'prefer-stable'
20+
21+
include:
22+
- laravel: '8.*'
23+
testbench: '6.*'
24+
25+
26+
27+
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} - ubuntu-latest
28+
29+
steps:
30+
- name: Checkout code
31+
uses: actions/checkout@v2
32+
33+
- name: Setup PHP
34+
uses: shivammathur/setup-php@v2
35+
with:
36+
php-version: ${{ matrix.php }}
37+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
38+
coverage: none
39+
40+
- name: Install dependencies
41+
run: |
42+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
43+
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
44+
45+
- name: Execute tests
46+
run: vendor/bin/phpunit tests

‎.gitignore‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
.idea
2-
vendor
2+
vendor
3+
.phpunit.result.cache
4+
coverage/
5+
.phpunit.cache/

‎README.md‎

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ Head over to the [Documentation](https://5amco.de/docs) of this package.
3636

3737
### 🔥 Code Examples to jumpstart your Notion API Project
3838

39-
#### Basic Setup
39+
#### Basic Setup (+ example)
4040
```php
41-
use FiveamCode\LaravelNotionApi\Notion;
42-
use Illuminate\Support\Collection;
43-
use FiveamCode\LaravelNotionApi\Query\Sorting;
44-
use FiveamCode\LaravelNotionApi\Query\Filter;
45-
46-
// Setup basic API connection
47-
$notion = new Notion();
48-
$notion->v1();
41+
use FiveamCode\LaravelNotionApi\Notion;
42+
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);
4949
```
5050

5151
#### Fetch Page Information
@@ -54,34 +54,41 @@ $notion->v1();
5454
$notion->pages()->find($yourPageId);
5555
```
5656

57+
#### Search
58+
```php
59+
// Returns a collection pages and databases of your workspace (included in your integration-token)
60+
\Notion::search($searchText)
61+
->query()
62+
->asCollection();
63+
```
64+
5765
#### Query Database
66+
5867
```php
5968
// Queries a specific database and returns a collection of pages (= database entries)
6069
$sortings = new Collection();
6170
$filters = new Collection();
6271

6372
$sortings
64-
->add(Sorting::propertySort("Ordered", "ascending"));
73+
->add(Sorting::propertySort('Ordered', 'ascending'));
6574
$sortings
66-
->add(Sorting::timestampSort("created_time", "ascending"));
75+
->add(Sorting::timestampSort('created_time', 'ascending'));
6776

6877
$filters
69-
->add(Filter::textFilter("title", ["contains" => "new"]));
78+
->add(Filter::textFilter('title', ['contains' => 'new']));
7079
// or
7180
$filters
72-
->add(Filter::rawFilter("Tags", ["multi_select" => ["contains" => "great"]]));
81+
->add(Filter::rawFilter('Tags', ['multi_select' => ['contains' => 'great']]));
7382

74-
$notion
75-
->database($yourDatabaseId)
76-
->filterBy($filters) // filters are optional
77-
->sortBy($sortings) // sorts are optional
78-
->limit(5) // limit is optional
79-
->query();
83+
\Notion::database($yourDatabaseId)
84+
->filterBy($filters) // filters are optional
85+
->sortBy($sortings) // sorts are optional
86+
->limit(5) // limit is optional
87+
->query()
88+
->asCollection();
8089
```
8190

8291

83-
84-
8592
### Testing
8693

8794
```bash
@@ -90,7 +97,11 @@ vendor/bin/phpunit tests
9097

9198
### Changelog
9299

93-
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
100+
Please see [CHANGELOG](https://5amco.de/docs/0.3.0/changelog) for more information what has changed recently.
101+
102+
## References / UsedBy
103+
104+
- 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.
94105

95106
## Contributing
96107

‎composer.json‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
"description": "Laravel Wrapper for the Notion API",
44
"keywords": [
55
"fiveam-code",
6-
"laravel-notion-api"
6+
"laravel-notion-api",
7+
"laravel",
8+
"notion",
9+
"notion-api",
10+
"api-wrapper"
711
],
812
"homepage": "https://github.com/fiveam-code/laravel-notion-api",
913
"license": "MIT",
@@ -13,10 +17,16 @@
1317
"name": "Diana Scharf",
1418
"email": "hello@dianaweb.dev",
1519
"role": "Developer"
20+
},
21+
{
22+
"name": "Johannes Güntner",
23+
"email": "johannes.guentner@it-guentner.de",
24+
"role": "Developer"
1625
}
1726
],
1827
"require": {
1928
"php": "^7.4|^8.0",
29+
"guzzlehttp/guzzle": "^7.0.1",
2030
"illuminate/support": "^8.0"
2131
},
2232
"require-dev": {
@@ -49,7 +59,7 @@
4959
"FiveamCode\\LaravelNotionApi\\LaravelNotionApiServiceProvider"
5060
],
5161
"aliases": {
52-
"LaravelNotionApi": "FiveamCode\\LaravelNotionApi\\LaravelNotionApiFacade"
62+
"Notion": "FiveamCode\\LaravelNotionApi\\NotionFacade"
5363
}
5464
}
5565
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /