Skip to content

Instantly share code, notes, and snippets.

@deleugpn
Created August 26, 2017 17:30
Show Gist options
  • Save deleugpn/c7406236e0a87cd06c5b7d3a509fda2d to your computer and use it in GitHub Desktop.
Save deleugpn/c7406236e0a87cd06c5b7d3a509fda2d to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\Resource;
class PostsResource extends Resource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'title' => $this->title,
'body' => $this->body
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment