on this page there are some examples, maybe you find something that point you in the right direction..
Your implementation is the prefered way since Father "IS A" Person. It is the same problem with building a Tree in a db (for example a menu with submenus....)
You have the added benefit that it can scale recursively (a Father also has a Father and Mother)
The only problem is SQL query efficiency if you nest too deep... There is an excellent article about optimizing hierarchical data in SQL: MANAGING HIERARCHICAL DATA IN MYSQL
Thank you for answers,
well, the DB strcture aside, I am still struggling implementing this in laravel and eloquent.
How should the relationships be designed?
How to output the whole tree in the view? Simple Foreach inside view? Some recursive function inside controller/model?
What if a person does not have one/both parents specified
etc..
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community