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

on this page there are some examples, maybe you find something that point you in the right direction..

http://www.laravelsd.com/

Last updated 9 years ago.
0

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

Last updated 9 years ago.
0

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..

Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

TorchSK torchsk Joined 17 Apr 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.