-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ltree relationships #81
Comments
Hmm, I‘ve not implemented a custom relationship class yet. But it could work. I think I could have a look at non-ltree tree relationship implementations. I guess then also a model cast would make sense. But in what should it be casted? An object that splits the parts in array elements? |
I haven't either. I googled for a bit and found this repo, but it does way too much for my liking, tbh: https://github.com/umbrellio/laravel-ltree I'm not sure what you mean with the model cast? Like a tree collection? The way I handled it was add a regular children property to my comment model (that was all I needed) and then just populated those within my tree builder. Doesn't seem very laravely, tbh ;) |
So you're only interested in the Its a nice idea. But I probably don't have the time for it currently. I've never implemented a relationship. So it needs a lot of fiddling around to find out how it works. |
Yup, scopes do make sense. Don't worry about working on it for now 😉 What I have works for my current project just fine and should it turn out later to not be enough, then I might give it a go myself at a later date. |
Just wondering out loud here, but would it be within the scope of this package to add relationships based on an
ltree
column? So something likechildren
,parent
andancestors
. Maybe even to a given depth?I've just used
ltree
for a comments system and ended up doing two queries. The first one gets a paginator just for the first level and the second one gets any children for the items in that paginator. I then have a tree class that builds up the hierarchy, sorts it properly and sets the resulting collection back on the paginator. It'll work just fine for my use case as there won't be many comments at all and even less nested ones, but it got me wondering if this couldn't be solved more efficiently.The text was updated successfully, but these errors were encountered: