Skip to content

Built tree from selecting specific nodes #6

@marvinschroeder

Description

@marvinschroeder

Let's say i have a tree like in your documentation with the "Catalog" and i would like to get the nodes "Samsung" in "Mobile" and "Apple" in "Netbooks" including all ancestor nodes up to the root, but without the root. All other nodes should not be included in the tree.

My code now looks like this:

$channels = array(4, 6);
Channel::withoutRoot()->whereIn('id', $channels)->get()->toTree();

But then i would only get the nodes "Samsung" and "Apple" and not the ancestor elements and so no tree could be built. Think of it as "a user has access on only specific nodes and the tree should be displayed up to the root".

I could get the specific nodes and built the tree up with one query per node, but this would be extremly overhead. Do you have any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions