Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Added some usage description for the new `dagRelationsOf()` scope.
  • Loading branch information
telkins authored Jul 31, 2020
1 parent fc6f3ee commit 64da260
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 64da260

Please sign in to comment.