You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I need feature in Laravel Eloquent Relationship. I wanna be able to make m2m relationship of the same model. For example:
I have a pivot table which contains two columns: issuer and friend. With User::with("contacts")->get() I want to get eager loaded relationship where user's id exists in issuerorfriend column. SQL query like this: SELECT * FROM `contacts` WHERE `issuer` = 1 OR `friend` = 1. So, I tried to use this:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I need feature in Laravel Eloquent Relationship. I wanna be able to make m2m relationship of the same model. For example:
I have a pivot table which contains two columns:
issuer
andfriend
. WithUser::with("contacts")->get()
I want to get eager loaded relationship where user's id exists inissuer
orfriend
column. SQL query like this:SELECT * FROM `contacts` WHERE `issuer` = 1 OR `friend` = 1
. So, I tried to use this:But it doesn't work in eager loading. I tried to found solution within 2 months and there are no results.
Beta Was this translation helpful? Give feedback.
All reactions