fenos
162
3
General

Extra Relation in Polymorphic Many to Many

Posted 4 years ago by fenos

Hi guys, I was wondering if is possible to have an extra relation on the pivot table that come polimorphycally.

I have the following schema simplified:

Team Table

- id
- name

Association Table

- id
- name

Coach Table

- id
- position

Pivot Table Coachable

- coach_id
- coachable_id
- coachable_type

- user_id // I would like have this field in relation 1 to 1 to my User Model

What I'm trying to achieve is a relation 1 to 1 from the user_id field in the pivot table to my User Model

Access on it like :

$team->coachable->user

Please sign in or create an account to participate in this conversation.