Closed jp2masa closed 1 year ago
Unfortunately, this kind of combination is not possible because recursive relationships can't be concatenated like "normal" relationships.
What you need instead is a BelongsToManyOfAncestors
relationship (equivalent to BelongsToManyOfDescendants
) and I'm working on that. I'll give you an update when the relationship is ready.
OK, thanks!
Any news on the progress @staudenmeir? I came across the same problem :/
I just released new versions for both packages that add support for relationships like yours.
You only need to remove the first ->newRelatedInstance(Category::class)
:
class Category extends Model
{
public function specifications()
{
return $this->hasManyDeepFromRelations(
$this->ancestorsAndSelf(),
$this->newRelatedInstance(Category::class)->directSpecifications()
);
}
}
Is this library compatible with laravel-adjacency-list?
I'm trying the following code but the relationship returns an empty array: