Level 51
3 likes
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I would like to transform the relationship json response for an API. Currently, i tried...
#model
return $this->hasMany()->select('parent_id','field1', 'field2', 'etc')
Also tried
#controller
Model::with('relationship:parent_id,field1,field2,etc')->get();
but it is showing the "parent_id" which i dont want to show.
How can i format the relationship to be able to hide and rename fields? I dont want to use the hidden attribute
Please or to participate in this conversation.