transformers
transformers copied to clipboard
nested relations
Hi, how would you set a specific transformation (multiple transformations feature) with pagination on a nested relation? Is this possible?
Currently its not supported, I'm not actively maintaining this, but you can try to add the name of the current default transformation in the transformers config. or any other kind of config, the idea is you are going to switch between them using config or whatever conditionals you would like to use.
and in your transformer you would do this:
public function getTransformation($item) {
if (config('transformers.user') === 'custom') {
return [
// your custom transformation.
];
}
return [
// the default transformation.
];
}
and in your controller or consumer code:
Config::set('transformers.user', 'custom'); // switch to custom transformation.