Support the ongoing development of Laravel.io →
Database Eloquent

Hi Guys :D

I need to reference People model with itself. My reference table has the following columns: id, id_person_1, id_person_2.

But when I use belongsToMany relationship I can`t search the results in the two columns (id_person_1 and id_person_2).

For exemple: if I have id_person_1 = 1, id_person_2 = 2, I don`t need to save id_person_1 = 2, id_person_2 = 1;

How can I do it ? What`s the better way?

Thank You!!!

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.