Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can this be used with belongsToMany? #1

Closed
joedawson opened this issue Jul 5, 2018 · 3 comments
Closed

Can this be used with belongsToMany? #1

joedawson opened this issue Jul 5, 2018 · 3 comments

Comments

@joedawson
Copy link

Hello,

Excellent package! I currently have the following relations;

User → belongsToMany → Area → hasMany → Venue

Is there a way for me to get the users venues? $user->venues;


A venue can then have "entries".

Venue → hasMany → Entry

I would then like to get the users entries based on the above. Is this possible?

My end goal would be to be able to do this;

// fetch the users venues based on the areas they're assigned to
$venues = $user->venues;

// fetch the users entries based on the venues the entries are assigned to (the above needs to be done first perhaps?)
$entries = $user->entries;

Hope you can help!

@joedawson
Copy link
Author

Sorry! I didn't scroll far enough down your documentation. Thank you so much.

return $this->hasManyDeep(Venue::class, [
    'area_user', Area::class
]);

I'm just working on fetching entries now.

@staudenmeir
Copy link
Owner

staudenmeir commented Jul 5, 2018

Use this:

return $this->hasManyDeep(Entry::class, [
    'area_user', Area::class, Venue::class
]);

@joedawson
Copy link
Author

@staudenmeir thank you so much for this. Working a charm! Appreciate the work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants