You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encountered the same issue, and after investigating, it seems the root cause is related to how the nested tree is retrieved.
In staudenmeir/laravel-adjacency-list, the correct way to get a nested tree structure is by using: Model::tree()->get()->toTree();
However, in this package, the method being used is: Model::get()->toTree();
This causes the nested tree to return duplicated data, which is unintended.
After looking into the issue further, I found a helpful suggestion from the author in this GitHub issue discussion.
To fix this, you can modify your relationship method like this:
What happened?
Hi,
I've 3 entries in my navigation_items database, a hasMany relationship to Navigation Model like this :
Navigation Model Table :
NavigationItem Model Table :
My Navigation Model is like this :
And this is my NavigationItemModel :
My AdjencyList is like this :
When I comment ->whereNull('parent_id') from my Navigation Model, items appears twice, like this :
But when I keep it, only parents appears :
I don't understand if it's a bug or If I do a mistake. I followed the documentation and got this. Any explications ?
Thanks you
How to reproduce the bug
Just create 2 models related with tables :
Navigation
NavigationItem :
And NavigationResource :
Package Version
2.2.1
PHP Version
8.2.0
Laravel Version
^11
Which operating systems does with happen with?
macOS
Notes
No response
The text was updated successfully, but these errors were encountered: