laravel-responder
laravel-responder copied to clipboard
Transformer mappings circular dependencies
Hey there, thanks for this awesome package. This particular issue has been mentioned and fixed previously in #106. I've got this:
class VariationTransformer extends Transformer
{
protected $load = [
'product' => ProductTransformer::class
];
public function transform(Variation $model): array
{
return [
'id' => $model->id,
'sku' => $model->sku,
'name' => $model->name
];
}
}
And this.
class ProductTransformer extends Transformer
{
protected $load = [
'variations' => VariationTransformer::class
];
public function transform(Product $model): array
{
return [
'name' => $model->name,
'description' => $model->description
];
}
}
The problem seems to be caused by the $load relationships calling each other. I'm using the latest version (3.1.2).