我有自定义的 eloquent api 资源user
。例如当我使用这个资源
代码
$user = $request->user();
return new UserResource($user);
然后在回应我得到:
{
"data": {
"name": "Margarete Daniel",
"email": "goldner.berniece@example.net",
"verified": "2020-03-20T07:15:56.000000Z"
}
}
我如何更改 api 资源并获得示例响应:
{
"name": "Margarete Daniel",
"email": "goldner.berniece@example.net",
"verified": "2020-03-20T07:15:56.000000Z"
}