Laravel – Return polymorphic relation grouped - development

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

Comments

Popular posts from this blog

HTTP 401 Unable to create record Twillio PHP sdk 5.16 - development

Using PHP and MySQL data to generate PDF letters like in MS Word mailmerge functionality - development

ng-include of inline SVG does not display gradient except in Chrome