E
E
Eugene2021-06-05 08:53:25
Laravel
Eugene, 2021-06-05 08:53:25

How to derive a relationship from a polymorphic pivot table?

Hello.
There is such structure of tables.
60bb101462c3d492234081.png
events is connected through personable (polymorphic relationship) with persons, and that, in turn, has roles through person_role. These roles I get like this

$event->persons()->with('roles')->paginate($paginate)

The problem is that each persons has a role that is tied to a specific event, and for this relationship, many to many is used from the personable polymorphic table.
How can I get the list of roles through a relationship from a polymorphic table?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question