Laravel – Return polymorphic relation grouped
I have a polymorphic relation :
Fields :
value
type
fieldable_id
fieldable_type
Customer :
id
name
...
I can acces my fields with $customer->fields
But I want to get my fields grouped by type like this :
phone => [Object Field]
[Object Field 2]
email => [Object Field 3]
[Object Field 4]
How can I do it?
I try with groupBy
but it has merged all of it into one and I have lost the others
Thank you
from Laravel Questions and Answers https://laravelquestions.com/laravel/laravel-return-polymorphic-relation-grouped/
via Lzo Media
No comments:
Post a Comment