Skip to content

Commit 96dec73

Browse files
committed
Profile docs
1 parent b769705 commit 96dec73

File tree

3 files changed

+81
-6
lines changed

3 files changed

+81
-6
lines changed

docs/.vuepress/3.0.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@ module.exports = [
3030
children: ['rest-methods/rest-methods'],
3131
},
3232
{
33-
title: 'Auth service',
33+
title: 'Auth',
3434
collapsable: true,
35-
children: ['auth/auth'],
35+
children: [
36+
'auth/auth',
37+
'auth/profile'
38+
],
3639
},
3740
{
3841
title: 'Error handler',

docs/docs/3.0/auth/auth.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# Authentication setup
22

3-
Laravel Restify has support for authentication with Passport or Laravel Airlock.
3+
Laravel Restify has support for authentication with Passport or Laravel Sanctum.
44

55
You'll finally enjoy the auth setup (`register`, `login`, `forgot` and `reset password`).
66

77
:::tip
88

9-
Firstly make sure you have setup the desired provider in the `restify.auth.provider`.
10-
and make sure you have installed and configured the Laravel Passport (or Restify) properly.
9+
Firstly make sure you have the setup the desired provider in the `restify.auth.provider`. Make sure you have installed and configured the [Laravel Sanctum](https://laravel.com/docs/7.x/sanctum#introduction) (or Passport) properly.
10+
1111
The passport check could be done easily by using the follow Restify command:
1212

1313
`php artisan restify:check-passport`
1414

15-
This command will become with suggestions if anything is setup wrong.
15+
This command will become with suggestions if any setup is invalid.
1616
:::
1717

1818
## Prerequisites

docs/docs/3.0/auth/profile.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# User Profile
2+
3+
[[toc]]
4+
5+
Laravel Restify expose the user profile via `GET: /restify-api/profile` endpoint.
6+
7+
## Get profile
8+
9+
Get profile:
10+
11+
// GET
12+
13+
```http request
14+
/restify-api/profile
15+
```
16+
17+
### Additional information
18+
19+
However, the default user information could be enough in many cases, you are still free to add your own information on the user profile.
20+
21+
```php
22+
// User.php
23+
24+
public function profile()
25+
{
26+
return [
27+
'roles' => [
28+
'admin',
29+
],
30+
];
31+
}
32+
```
33+
34+
## Update Profile
35+
36+
Restify will update only `fillable` user attributes present in the request payload: `$request->only($user->getFillable())`.
37+
38+
// PUT
39+
40+
```http request
41+
/restify-api/profile
42+
```
43+
44+
45+
## User avatar
46+
47+
If your user has an avatar, you can use the Restify endpoints to update the avatar:
48+
49+
// POST
50+
51+
```http request
52+
restify-api/profile/avatar
53+
```
54+
55+
The payload could be a form data, with an image under `avatar` key.
56+
57+
The default path for storing avatar is: `/avatars/{user_key}/`.
58+
59+
You can modify that by modifying property in a `boot` method of any service provider:
60+
61+
```php
62+
Binaryk\LaravelRestify\Http\Requests\ProfileAvatarRequest::$path
63+
```
64+
65+
Or if you need the request to make the path:
66+
67+
```php
68+
Binaryk\LaravelRestify\Http\Requests\ProfileAvatarRequest::usingPath(function(Illuminate\Http\Request $request) {
69+
return 'avatars/' . $request->user()->uuid
70+
})
71+
```
72+

0 commit comments

Comments
 (0)