Skip to content

Instantly share code, notes, and snippets.

@fieldAbyss
Created July 5, 2018 15:22
Show Gist options
  • Save fieldAbyss/6c623a2431de8ffb6f1d9136c7e9d71b to your computer and use it in GitHub Desktop.
Save fieldAbyss/6c623a2431de8ffb6f1d9136c7e9d71b to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\Resource;
class UserResource extends Resource
{
/**
* リソースを配列へ変換する
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
// 下記の行を追加してオーバーライドする。
Resource::wrap('');
return [
'id' => $this->id,
'name' => $this->name,
'email' => $this->email,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment