HasManyThrough with two pivot tables

Posted 3 years ago by wheredidgogogo

This one is starting to fry my brain...

I have five tables:

users

roles_users (pivot)

roles

permissions_roles (pivot)

permissions

I can't for the life of me create a query that returns the permissions for a given user.

I can get hasmanythrough to work with just one pivot table and a one-to-one relationship for the second step. But I can't get it to work when there are 2 many-to-many relationships.

Any help would be greatly appreciated :)

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.