Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transformer mappings circular dependencies #171

Open
mauriciovillam opened this issue Dec 11, 2020 · 0 comments
Open

Transformer mappings circular dependencies #171

mauriciovillam opened this issue Dec 11, 2020 · 0 comments

Comments

@mauriciovillam
Copy link

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant