Skip to content

Commit bc228d3

Browse files
committed
[Docs] Update readme with tutorial details
1 parent 1a2205e commit bc228d3

File tree

1 file changed

+89
-1
lines changed

1 file changed

+89
-1
lines changed

README.md

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,98 @@
55
Implement feature-rich [JSON:API](https://jsonapi.org) compliant APIs in your
66
[Laravel](https://laravel.com) applications. Build your next standards-compliant API today.
77

8+
### Why use JSON:API?
9+
10+
- Standardised, consistent APIs.
11+
- Feature rich - some of which are filtering, pagination, eager loading and sparse fieldsets.
12+
- Easy to understand.
13+
14+
### Why use Laravel JSON:API?
15+
16+
- Saves a lot of development time.
17+
- Highly maintainable code.
18+
- Great, extensive documentation.
19+
- Strong conventions, but also highly customisable.
20+
- Makes use of native Laravel features such as policies and form requests to make the shift easier for developers.
21+
- Beautiful, expressive Nova-style schemas.
22+
- Fully testable via expressive test helpers.
23+
24+
```php
25+
class PostSchema extends Schema
26+
{
27+
28+
/**
29+
* The model the schema corresponds to.
30+
*
31+
* @var string
32+
*/
33+
public static string $model = Post::class;
34+
35+
/**
36+
* The maximum include path depth.
37+
*
38+
* @var int
39+
*/
40+
protected int $maxDepth = 3;
41+
42+
/**
43+
* Get the resource fields.
44+
*
45+
* @return array
46+
*/
47+
public function fields(): array
48+
{
49+
return [
50+
ID::make(),
51+
BelongsTo::make('author')->type('users')->readOnly(),
52+
HasMany::make('comments')->readOnly(),
53+
Str::make('content'),
54+
DateTime::make('createdAt')->sortable()->readOnly(),
55+
DateTime::make('publishedAt')->sortable(),
56+
Str::make('slug'),
57+
BelongsToMany::make('tags'),
58+
Str::make('title')->sortable(),
59+
DateTime::make('updatedAt')->sortable()->readOnly(),
60+
];
61+
}
62+
63+
/**
64+
* Get the resource filters.
65+
*
66+
* @return array
67+
*/
68+
public function filters(): array
69+
{
70+
return [
71+
WhereIdIn::make($this),
72+
WhereIn::make('author', 'author_id'),
73+
];
74+
}
75+
76+
/**
77+
* Get the resource paginator.
78+
*
79+
* @return Paginator|null
80+
*/
81+
public function pagination(): ?Paginator
82+
{
83+
return PagePagination::make();
84+
}
85+
}
86+
```
87+
888
## Documentation
989

1090
See our website, [laraveljsonapi.io](https://laraveljsonapi.io)
1191

92+
### Tutorial
93+
94+
New to JSON:API and/or Laravel JSON:API? Then
95+
the [Laravel JSON:API tutorial](https://laraveljsonapi.io/docs/1.0/tutorial/)
96+
is a great way to learn!
97+
98+
Follow the tutorial to build a blog application with a JSON:API compliant API.
99+
12100
## Installation
13101

14102
Install using [Composer](https://getcomposer.org)
@@ -32,7 +120,7 @@ composer up laravel-json-api/* cloudcreativity/json-api-testing
32120
## Example Application
33121

34122
To view an example Laravel application that uses this package, see the
35-
[Dummy Application](https://github.com/laravel-json-api/laravel/tree/main/tests/dummy) within the tests folder.
123+
[Tutorial Application](https://github.com/laravel-json-api/tutorial-app).
36124

37125
## License
38126

0 commit comments

Comments
 (0)