Skip to content
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

Can it run alongside laravel-nestedset? #113

Closed
sawirricardo opened this issue Jun 9, 2022 · 10 comments
Closed

Can it run alongside laravel-nestedset? #113

sawirricardo opened this issue Jun 9, 2022 · 10 comments

Comments

@sawirricardo
Copy link

Hi, great package, really love it.

I was thinking maybe we can try to make this package co-existable with current nested-set? Since it has some features I would love to use that doesn't require nested set, but didn't want to leave the nested set too.

https://github.com/lazychaser/laravel-nestedset

currently, if we just install this, it will have conflicting methods such as parents and children relationship...

@staudenmeir
Copy link
Owner

staudenmeir commented Jun 9, 2022

Hi @sawirricardo,
How does/would your database structure look like? Would you have both the parent_id column for this package and the lft & rgt columns for nested sets in the same table?

@sawirricardo
Copy link
Author

yes, _lft and _rgt to be precise, that's the nested set package standard way,

@sawirricardo
Copy link
Author

and I think should not the columns be in 1 table though? haven't seen structures which has lft/rgt and parent_id in different places 🤔

@staudenmeir
Copy link
Owner

and I think should not the columns be in 1 table though? haven't seen structures which has lft/rgt and parent_id in different places 🤔

I didn't mean in comparison to having the columns in multiple tables, but I wanted to confirm that you want to have the columns for both packages at the same time. It sounds quite cumbersome to always keep two sets of hierarchies up-to-date and in sync.

currently, if we just install this, it will have conflicting methods such as parents and children relationship...

You should be able to solve the conflicts with method aliases:
https://www.php.net/manual/en/language.oop5.traits.php#language.oop5.traits.conflict

@staudenmeir
Copy link
Owner

staudenmeir commented Jun 9, 2022

I just looked at the actual conflicts: You can solve the conflicts for methods like ancestors and children with aliases, but the conflicts for newCollection and especially newEloquentBuilder are different: You would have to manually merge classes of the two packages which is probably possible but looks like quite a lot of work.

@staudenmeir
Copy link
Owner

Does lazychaser/laravel-nestedset offer any features that you are missing from this package?

@sawirricardo
Copy link
Author

the motivation behind me is the uncertain to pick exactly 1 package between these two, hence the thinking to why not use both, but if it isn't possible, that's okay. Do you have any situation say... when you will pick this package rather than nested set? or vice versa?

@staudenmeir
Copy link
Owner

hence the thinking to why not use both, but if it isn't possible, that's okay.

Unfortunately, you would have to spend some time to make that work.

Do you have any situation say... when you will pick this package rather than nested set? or vice versa?

I'm biased, of course, but for me the big advantage of this package is that you can use the "native" table structure for hierarchies that only requires a parent_id column. This makes inserting/updating/deleting nodes as easy as possible.
There's apparently no difference in performance: #83

@sawirricardo
Copy link
Author

Great to hear that... I've implemented in this package https://github.com/sawirricardo/indonesia-region to simplify the usage for recursive elements

@decadence
Copy link
Contributor

Yes, advantage of this package: it doesn't need to build left / right positions every time so tree can't be broken on parallel update / inserts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants