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

makeRoot() with tree #83

Open
sieulog opened this issue Oct 20, 2015 · 1 comment
Open

makeRoot() with tree #83

sieulog opened this issue Oct 20, 2015 · 1 comment
Assignees
Labels

Comments

@sieulog
Copy link

sieulog commented Oct 20, 2015

Hello Everybody!

I have 2 tables below:

vocabulary:
----id
----title
data example
id = 1; title = news
id = 2; title = products
id = 3; title = gallery
taxonomy:
----id
----vocabulary_id
----lft
----rgt
----depth
----title
----slug
...
with vocabulary_id = tree

I config behavior tree is vocabulary_id. But when I make root with function makeRoot() with follow:

$taxonomy = new Taxonomy([
'vocabulary_id' => 1, //news
'title' => 'News Cat A'
]);
$taxonomy->makeRoot();

I seen vocabulary_id = 1; lft = 1, rgt = 2, depth = 0, title = "News Cat A' ===> OK
but when I try with follow:
$taxonomy = new Taxonomy([
'vocabulary_id' => 3, //gallery
'title' => 'Gallery Cat A'
]);
$taxonomy->makeRoot();
I seen vocabulary_id = 2; lft = 1, rgt = 2, depth = 0, title = "Gallery Cat A' ===> Not good. Because I want vocabulary = 3

@creocoder
Copy link
Owner

You can't set treeAttribute, leftAttribute, rightAttribute to custom values. They restricted by design. Due to NS nature treeAttribute should be equal to id so you can't use treeAttribute as FK for another table. I think in your case its good idea to add additional field.

@creocoder creocoder self-assigned this Oct 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants