Closed abodnar closed 8 years ago
yes, you have to set the key value pair,
the $availableIncludes is for the sub relationship which is available under the current object.
eg. http://api.example.com/users/1?include=order
by referring to the sample url above, if you have set $availableInclude = ['order'];
,
or
Fractal::includes('order')->collection($users, new UserTransformer());
and having a method includeOrder()
, the includeOrder will be loaded and injected into your api response.
and $defaultIncludes
will always be call and injected on every single transformation.
In the transform function of my transformer, do I have to return an array? And do I have to set every single key in the array for what I want returned?
Or am I able to just change the points of data on the object and return the object?
Something like this:
`class Transformer extends TransformerAbstract { public function transform($obj) { $obj->id = md5($obj->id);
} } `
Also, what do you typically put in $availableIncludes and $defaultIncludes?