Is it better to have multiple
Transformers over a single transformer per model?
I want to exclude a fields from the JSON response when listing items. Although when retrieving a single item I want all fields. Would a
PostListTransformer and a
PostTransformer be appropriate, or should i use the "includes" feature of Fractal?
Also I would like the ability to include extra fields AND relations in the
Examples will be well regarded, Laravel Eloquent is the ORM.
What you could do is add a $fields property that gets populated with the fields you only need through your transformer's constructor method, then create a method that uses those fields (if any exist) to filter out your transform() method output. You can find some code for it in one of the closed issues in the fractal github repo