Skip to content

Get a Tree from a Graph (Many-toMany) Relationship and filter it #217

Answered by staudenmeir
nilskretschmer asked this question in Q&A
Discussion options

You must be logged in to vote

Try adding a custom recursive query constraint:
https://github.com/staudenmeir/laravel-adjacency-list#graphs-recursive-query-constraints

$pageComponents = Component::withRecursiveQueryConstraint(function (Builder $query) use ($page) {
   $query->where('component_page.page_id', $page->id);
}, function () use ($constraint) {
   return Component::subgraph($constraint)->get();
});

Replies: 9 comments 16 replies

Comment options

You must be logged in to vote
1 reply
@nilskretschmer
Comment options

Comment options

You must be logged in to vote
1 reply
@nilskretschmer
Comment options

Comment options

You must be logged in to vote
1 reply
@nilskretschmer
Comment options

Comment options

You must be logged in to vote
1 reply
@nilskretschmer
Comment options

Comment options

You must be logged in to vote
1 reply
@nilskretschmer
Comment options

Comment options

You must be logged in to vote
1 reply
@nilskretschmer
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
10 replies
@nilskretschmer
Comment options

@staudenmeir
Comment options

@staudenmeir
Comment options

@nilskretschmer
Comment options

@staudenmeir
Comment options

Answer selected by nilskretschmer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants