I have a polymorphic "Relationships" many to many relation that looks like that:
users
id | first_name | last_name
groups
id | group_name
regions
id | region_name
relationships
id | user_id | relationship_id | relationship_type | relationship_level
4 | 13 | 25 | App\Group | Group Manager
5 | 20 | 18 | App\Region | Participant
When I have an array of IDs, I want to select the relationships that exactly match between the users, this means that all columns (except user_id) match.
And they should only be rows that match among all users. If only 10 out of 12 selected users have the same relationship it should not be included.
If I select 10 users I need to select a pivot record that all those 10 users have (if any).
It doesn't matter if done in eloquent or via the collection after fetching from Database.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire