I have a menu in the database like everyone else:
id | parent_id | url |
---|---|---|
1 | 0 | clothes |
2 | 1 | men |
3 | 2 | pants |
3 | 1 | women |
4 | 3 | pants |
I'm coming web.com/clothes/men/pants
, I catch the url in the controller:
It is very inconvenient to always collect all the URLs:
- For the menu
- To understand what category we are in in order to show the product correctly
Maybe should I immediately store the full urls in the database?
There are 1800 categories in total! And cache everything!
id | parent_id | url |
---|---|---|
1 | 0 | clothes |
2 | 1 | clothes/men |
3 | 2 | clothes/men/pants |
3 | 1 | clothes/women |
4 | 3 | clothes/women/pants |