Can anyone provide any guidance on this?
Thanks
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Ok guys, here's the thing....
I've created a model for Categories which works nicely with Sub Categories (from an Eloquent perspective)
Cat 1
Cat 1 -> Sub 1
Cat 1 -> Sub 1 -> Sub 2
Cat 1 -> Sub 1 -> Sub 2 -> Sub 3
I really don't want to limit the depth unless I have to.
I then have a Product Model, and any given Product can be associated to any level of category, I had in mind that a Product would be placed in the lowest category, and roll up, but I may have it so that it needs to be placed at every level - we'll see.
URL's will look like this (all driven on slugs)
/cat1/sub2/sub3/product-name
/cat3/product-name
/cat1/sub2/product-name
So a few questions
I'm considering some kind of centralised slug management, which allows unique slugs and determines the correct controller to hand off to. Seems complex.
Part of me things I should just do
/cat1
/sub2 (which is really /cat1/sub2)
/sub3/product-name
{category}
{category}/{product}
I just feel, for nested categories, you lose some readability if the categories don't stack in the address bar and tell a story?
I welcome all and any feedback.
Please or to participate in this conversation.