Resources are for individual models.
php artisan make:resource User
For collections use Resource Collections
I think these are optional, just if you want additional metadata
php artisan make:resource Users --collection php artisan make:resource UserCollection
To use collections:
'email' => $this->email, 'posts' => PostResource::collection($this->posts), 'created_at' => $this->created_at,
Default is in
data but this can be disabled with withoutWrapping.
this adds the ```meta``` and ```links``` keys. ## Conditional Attributes ```when``` can be used to conditionally add attributes:
‘secret’ => $this->when(Auth::user()->isAdmin(), ‘secret-value’),
## Merging Conditional Attributes
$this->mergeWhen(Auth::user()->isAdmin(), [ 'first-secret' => 'value', 'second-secret' => 'value', ]), ```