diff --git a/README.md b/README.md index 4675e33..aad5416 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,22 @@ $tree = User::tree(3)->get(); $tree = User::treeOf($constraint, 3)->get(); ``` +You can also chaperone tree relations to load parent/ancestor relations already present in the tree to (potentially) reduce 1+n queries: + +```php +$tree = User::tree(3)->get(); + +$tree->loadTreePathRelations(); +``` + +Or via `toTree`: + +```php +$users = User::tree(1)->get(); + +$tree = $users->loadTreePathRelations()->toTree(); +``` + #### Filters The trait provides query scopes to filter models by their position in the tree: