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

There is no prepared methods? I must use array_walk_recursive?

0

I have the exact identical question.

How did you resolved finally?

0

I would suggest using the correct schema setup for such a thing. Data in a hierarchy like this would require recursion unless using certain patterns to avoid this type of recursion. Especially when dealing with unknown depths.

Something like nested sets or closure table would be easier for querying to retrieve all descendents or parents, etc.

0

You could also go fancy use neo4j with graphs which then just traverse it for you. If you are going to do this quite frequent and you dont know how far it span - a graph approach might be good

Also the package for it is quite up to date up to Laravel 5.2 https://github.com/Vinelab/NeoEloquent

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Aneta1990 aneta1990 Joined 3 Mar 2016

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.