You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 14, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+45-1Lines changed: 45 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,15 +6,59 @@ Integrate JSON:API resources on Laravel.
6
6
7
7
**Note: This package is under active development and initial stage, please DON'T use it for production purposes.**
8
8
9
+
## Installation
10
+
11
+
You can install the package via composer:
12
+
13
+
```
14
+
composer require skore-labs/laravel-json-api
15
+
```
16
+
17
+
### Usage
18
+
19
+
As simple as importing the class `SkoreLabs\JsonApi\Http\Resources\JsonApiCollection` for collections or `SkoreLabs\JsonApi\Http\Resources\JsonApiResource` for resources.
20
+
21
+
```php
22
+
<?php
23
+
24
+
namespace App\Http\Controllers;
25
+
26
+
use Illuminate\Http\Request;
27
+
use SkoreLabs\JsonApi\Http\Resources\JsonApiCollection;
28
+
use App\User;
29
+
30
+
class UserController extends Controller
31
+
{
32
+
/**
33
+
* Display a listing of the resource.
34
+
*
35
+
* @return \Illuminate\Http\Response
36
+
*/
37
+
public function index()
38
+
{
39
+
return new JsonApiCollection(
40
+
User::simplePaginate()
41
+
);
42
+
}
43
+
}
44
+
```
45
+
9
46
## Features
10
47
11
48
- Full formatting using pure built-in model methods and properties.
12
49
- Relationships and nested working with [eager loading](https://laravel.com/docs/master/eloquent-relationships#eager-loading).
13
50
- Permissions "out-of-the-box" authorising each resource view or list of resources.
51
+
- Auto-hide not allowed attributes from responses like `user_id` or `post_id`.
14
52
15
53
## Recommendations
16
54
17
-
These packages are recommended for a better
55
+
These packages are recommended (and suggested by the package installation) for a better integration with JSON:API standards:
0 commit comments