Skip to content
This repository was archived by the owner on Feb 14, 2023. It is now read-only.

Commit ce6b46c

Browse files
authored
Update readme with more usage info
1 parent ae43ea1 commit ce6b46c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,21 @@ class UserController extends Controller
4343
}
4444
```
4545

46+
### Authorisation
47+
48+
For authorize a resource or collection you'll need the `view` and `viewAny` on the **model policy**, which you can create passing the model to the make command:
49+
50+
```
51+
php artisan make:policy UserPolicy -m User
52+
```
53+
54+
Alternatively, you can pass an authorisation (boolean) to the constructor of the resource like this:
55+
56+
```php
57+
// Forced to allow view the user
58+
return new JsonApiResource($user, true);
59+
```
60+
4661
## Features
4762

4863
- Full formatting using pure built-in model methods and properties.

0 commit comments

Comments
 (0)