Jan 7, 2021
0
Level 2
Receiving a pivot relation through another pivot relation
Hello,
I was wondering if it is possible to make a relation function to directly retrieve models with two pivots in between. We created the following models/pivots:
Group
functions: users, websites
GroupUser (pivot)
columns: group_id, user_id
functions: group, user
GroupWebsite (pivot)
columns: group_id, website_id
functions: group, website
Website
functions: groups, users(?)
User
functions: groups, websites(?)
Is it possible to get a websites relation directly from the user class or is it only possible to retreive all groups and then the websites from the groups with multiple queries?
Please or to participate in this conversation.