laravel-api-boilerplate icon indicating copy to clipboard operation
laravel-api-boilerplate copied to clipboard

WithPivot removed during transformation

Open DrRamazzotti opened this issue 1 year ago • 3 comments

I have a many to many relation with additional fields.

It works fine until I try to query a item or collection with additional fields.

Return the "pure" raw item the additional pivot fields are there.

Using return $this->response->item($company, $this->getTransformer()); the additional fields wont appear.

DrRamazzotti avatar Jan 14 '24 14:01 DrRamazzotti

Hey @DrRamazzotti could you please provide some code examples of your models and the route you are calling?

specialtactics avatar Feb 11 '24 09:02 specialtactics

Hi Max,

In the meantime I got a glue.

vendor/specialtactics/l5-api/src/Transformers/RestfulTransformer.php

There is the issue

Lines 232 to 234

// We don't really care about pivot information at this stage if (isset($transformedRelatedModel['pivot'])) { unset($transformedRelatedModel['pivot']); }

Its just coded that while transformation it's removed

Bernhard


Von: Max @.> Gesendet: Sonntag, 11. Februar 2024 10:40 An: specialtactics/laravel-api-boilerplate @.> Cc: DrRamazzotti @.>; Mention @.> Betreff: Re: [specialtactics/laravel-api-boilerplate] WithPivot removed during transformation (Issue #71)

Hey @DrRamazzottihttps://github.com/DrRamazzotti could you please provide some code examples of your models and the route you are calling?

— Reply to this email directly, view it on GitHubhttps://github.com/specialtactics/laravel-api-boilerplate/issues/71#issuecomment-1937494186, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AELGECWHFUIJD5DERTYPLW3YTCGZTAVCNFSM6AAAAABB2D37CSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZXGQ4TIMJYGY. You are receiving this because you were mentioned.

DrRamazzotti avatar Feb 13 '24 14:02 DrRamazzotti

Hey @DrRamazzotti - happy to work on this, but can you give me some examples of how you are using pivots? Can you post some example models and a controller code and what you expect?

specialtactics avatar Jul 17 '24 00:07 specialtactics