You need an extra column in your category table, that will hold the parent category's id. Such that for all your top categories this will have 0, then all the child categories have the parent category value. See e.g. below
id name parent_id
1 pet 0
2 cat 1
3 dog 1
4 vehicle 0
5 sedan 4
6 truck 4
Hope this helps
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community