Support the ongoing development of Laravel.io →
posted 10 years ago
Database
Last updated 2 years ago.
0

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

Last updated 2 years ago.
0
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

gogs85 gogs85 Joined 15 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.