Skip to content

Commit

Permalink
Merge branch 'master' of github.com:telkins/laravel-dag-manager
Browse files Browse the repository at this point in the history
  • Loading branch information
telkins committed Aug 8, 2020
2 parents 5db09b8 + 64da260 commit 1b5aad4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,12 @@ $ancestors = MyModel::dagAncestorsOf($myModel->id, 'my-source')->get();

Again, an ID and source must be provided.

Both of the aforementioned methods also allow the caller to constrain the results based on the number of hops. So, if you want to get the immediate children of the specified model ID, then you could do the following:
Finally, one can apply a scope that will get both ancestors and descendants:
```php
$ancestors = MyModel::dagRelationsOf($myModel->id, 'my-source')->get();
```

Each of the aforementioned methods also allow the caller to constrain the results based on the number of hops. So, if you want to get the immediate children of the specified model ID, then you could do the following:
```php
$descendants = MyModel::dagDescendantsOf($myModel->id, 'my-source', 0)->get();
```
Expand All @@ -131,7 +136,7 @@ And, of course, in order to get the parents and grandparents of the specified mo
$ancestors = MyModel::dagAncestorsOf($myModel->id, 'my-source', 1)->get();
```

Not providing the `$maxHops` parameter means that all descendants or ancestors will be returned.
Not providing the `$maxHops` parameter means that all descendants, ancestors, or relations will be returned.

## Testing

Expand Down

0 comments on commit 1b5aad4

Please sign in to comment.