for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class ThingResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
return array_merge(
[
'type' => 'thing',
'id' => $this->id,
id
App\Http\Resources\ThingResource
__get
'created_at' => $this->created_at->toDateTimeString(),
created_at
'updated_at' => $this->updated_at->toDateTimeString(),
updated_at
'items' => ItemResource::collection($this->whenLoaded('items')),
'image' => $this->image,
image
],
$this->properties->toArray()
properties
);
}