transformers icon indicating copy to clipboard operation
transformers copied to clipboard

nested relations

Open mitjarobic opened this issue 8 years ago • 1 comments

Hi, how would you set a specific transformation (multiple transformations feature) with pagination on a nested relation? Is this possible?

mitjarobic avatar May 16 '17 22:05 mitjarobic

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.

logaretm avatar May 16 '17 23:05 logaretm