first commit
This commit is contained in:
30
app/Http/Resources/User.php
Normal file
30
app/Http/Resources/User.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class User extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => [
|
||||
'type' => 'users',
|
||||
'user_id' => $this->id,
|
||||
'attributes' => [
|
||||
'name' => $this->name,
|
||||
],
|
||||
],
|
||||
'links' => [
|
||||
'self' => url('/users/'.$this->id),
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user