laravel-nestedset icon indicating copy to clipboard operation
laravel-nestedset copied to clipboard

siblings() relationship

Open ven0ms99 opened this issue 7 months ago • 0 comments

I migrated from laravel-adjacency-list due to the read-performance benefits. However, I am missing some relations, especially the siblings() relationship.

I know I can simply get the siblings, but I need to get them in a whereHas() relation.

For now, I am using both packages at the same time, which really isn't ideal and also only works, because they both offer a siblings() method:

use NodeTrait, HasAdjacencyList {
        NodeTrait::descendants insteadof HasAdjacencyList;
        NodeTrait::parent insteadof HasAdjacencyList;
        NodeTrait::ancestors insteadof HasAdjacencyList;
        NodeTrait::children insteadof HasAdjacencyList;
        NodeTrait::newCollection insteadof HasAdjacencyList;
        NodeTrait::newEloquentBuilder insteadof HasAdjacencyList;
        NodeTrait::isChildOf insteadof HasAdjacencyList;

        HasAdjacencyList::siblings insteadof NodeTrait;
        HasAdjacencyList::siblingsAndSelf insteadof NodeTrait;
    }

I tried to implement the siblings() relationship myself, but I didn't manage to do it. Maybe someone else with more experience can charm in. Would be highly appreciated!

ven0ms99 avatar Mar 06 '25 22:03 ven0ms99