40 lines
1.2 KiB
PHP
40 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
/**
|
|
* @OA\Schema(
|
|
* schema="UserResource",
|
|
* @OA\Property(property="id", type="integer", example=1),
|
|
* @OA\Property(property="username", type="string", example="root"),
|
|
* @OA\Property(property="email", type="string", example="root@example.com"),
|
|
* @OA\Property(property="email_verified_at", type="string", format="date-time"),
|
|
* @OA\Property(property="type", type="string", example="user"),
|
|
* @OA\Property(property="created_at", type="string", format="date-time"),
|
|
* @OA\Property(property="updated_at", type="string", format="date-time")
|
|
* )
|
|
*/
|
|
class UserResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'username' => $this->username,
|
|
'email' => $this->email,
|
|
'email_verified_at' => $this->email_verified_at,
|
|
'type' => $this->type,
|
|
'created_at' => $this->created_at,
|
|
'updated_at' => $this->updated_at,
|
|
];
|
|
}
|
|
}
|