specialtactics / laravel-api-boilerplate

Laravel API Boilerplate | Quickly build quality API products!
MIT License
495 stars 96 forks source link

WithPivot removed during transformation #71

Open DrRamazzotti opened 8 months ago

DrRamazzotti commented 8 months ago

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.

specialtactics commented 7 months ago

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

DrRamazzotti commented 7 months ago

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.

specialtactics commented 2 months ago

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?