Descendants of laravel. 0 Laravel 5. Jan 1, 2017 · Laravel return all the ids of descendants Asked 8 years, 6 months ago Modified 4 years, 5 months ago Viewed 6k times Hello in users table : |Id|Name |TeamLeader| |--|-------------------------------|----------| |1 |name 1 |3 | |2 |name 2 |7 | |3 |name 3 |5 | |4 |name 4 |5 | |5 |name Aug 27, 2025 · This works with Ancestors, Bloodline and Descendants relationships (Laravel 9+). What I want is to flatten all those collection including all those descendants of parent. Consider a HasMany relationship between User and Post and building a deep relationship to get all posts of a user's descendants: The other one is to play with the eager loaded collection and try to parse it to either Json string or array and then recursively retrieve each descendant's whatever attributes want, in both cases will be through deeply nested. Contribute to lazychaser/laravel-nestedset development by creating an account on GitHub. 7, 5. Laravel Adjacency List This Laravel Eloquent extension provides recursive relationships for trees and graphs using common table expressions (CTE). Consider a HasMany relationship between User and Post and building a deep relationship to get all posts of a user's descendants: Firstly, thank you @staudenmeir for making this package. x Eloquent recursive relationship - get all ids Asked 4 years ago Modified 4 years ago Viewed 1k times I have a parent children relationship on my model. For example, you can fetch all descendants of a node in a single query, no matter how deep the tree. ynqwj306h48ruq0kyiqddfgvayl9ithd76ckbbrysz4yd5