mardi 2 mai 2017

Laravel - Eloquent. Autoreference another row inside the same table/model

I have a Group.php model. The db table is like the columns: id, title, description, parent.

The parent column has reference to a id of another group inside this table. So if a record has value in parent column then it is a child of another group. How can I go with eloquent and get the hierarchy of the the nested groups.

I want to use this so when I am in blade I want to do foreach for the outer parent groups and then do foreach for each child to see if has any other child and then do foreach again.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire