Created
July 5, 2018 15:22
-
-
Save fieldAbyss/6c623a2431de8ffb6f1d9136c7e9d71b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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