Sasa is a highly driven full stack software developer with background in finance and accounting. A relentless problem solver who is passionate about finding elegant solutions to problems at hand.
Well this is how it looks in my panel. I used the jQuery Nestable for the drag and drop list.
As far as the logic goes, I have a categories table, that has a category_id foreign key on itself that is nullable.
If it is null it's a "root" category, if it has a value, it is a child category (subcategory). I also have a level column which represents the depth of the child category.
Additionally I added a sort column, which allows me to sort them easier. All of the categories including the child categories are sorted in chronological order, so instead of doing complex queries every time my API is hit for the category tree, I do them after CUD operations and just update the sort column which is a simple INT.
When I build the tree in the code, I start from the root and attach the "branches" with a recursive function.
Sasa is a highly driven full stack software developer with background in finance and accounting. A relentless problem solver who is passionate about finding elegant solutions to problems at hand.
Well this is how it looks in my panel. I used the jQuery Nestable for the drag and drop list.
As far as the logic goes, I have a
categories
table, that has acategory_id
foreign key on itself that is nullable.If it is null it's a "root" category, if it has a value, it is a child category (subcategory). I also have a
level
column which represents the depth of the child category.Additionally I added a
sort
column, which allows me to sort them easier. All of the categories including the child categories are sorted in chronological order, so instead of doing complex queries every time my API is hit for the category tree, I do them after CUD operations and just update the sort column which is a simple INT.When I build the tree in the code, I start from the root and attach the "branches" with a recursive function.
That's the general gist, thanks for asking!
Neat!
Well thank you!