Skip to content

Commit c513729

Browse files
committed
Update README
1 parent de796a7 commit c513729

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

README.md

+47-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,53 @@ All you need to do is to run the following command:
1818
php artisan alibori:api-resource <model-name>
1919
```
2020

21-
This command will generate a new resource for the given model name with the properties defined in the model.
21+
This command will generate a new resource for the given model name with the properties defined in the model. For example, for the model named `User` you will get the following resource:
22+
23+
``` php
24+
<?php
25+
26+
namespace App\Http\Resources;
27+
28+
use Illuminate\Contracts\Support\Arrayable;
29+
use Illuminate\Http\Request;
30+
use Illuminate\Http\Resources\Json\JsonResource;
31+
use JsonSerializable;
32+
33+
/**
34+
*
35+
*
36+
* @property $id
37+
* @property $name
38+
* @property $email
39+
* @property $email_verified_at
40+
* @property $password
41+
* @property $remember_token
42+
* @property $created_at
43+
* @property $updated_at
44+
*/
45+
class UserResource extends JsonResource
46+
{
47+
/**
48+
* Transform the resource into an array.
49+
*
50+
* @param Request $request
51+
* @return array|Arrayable|JsonSerializable
52+
*/
53+
public function toArray($request): array|JsonSerializable|Arrayable
54+
{
55+
return [
56+
'id' => $this->id,
57+
'name' => $this->name,
58+
'email' => $this->email,
59+
'email_verified_at' => $this->email_verified_at,
60+
'remember_token' => $this->remember_token,
61+
'created_at' => $this->created_at,
62+
'updated_at' => $this->updated_at
63+
];
64+
}
65+
}
66+
67+
```
2268

2369
## Publish config file
2470

0 commit comments

Comments
 (0)