How to set keys for relation between three tables (many to many):
distributor_contacts
distributor_contacts_instructor
distributor_instructors
Where distributor_contacts_instructor
is intermediate table:
| instructor_id | distributor_contacts_id
Where distributor_contacts
table is:
| user_id |
Where distributor_instructors
is:
| user_id |
I need to store in distributor_contacts_instructor
value distributor_instructors.user_id
to distributor_contacts_instructor.instructor_id
and distributor_contacts_instructor.distributor_contacts_id
to Auth::user()->id
How to set this relation in model below?
return $this->belongsToMany(DistributorContacts::class, 'distributor_contacts_instructor', 'instructor_id', 'distributor_contacts_id', 'user_id', 'user_id');
I tried, but it does not work
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire