Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Commit

Permalink
Add documentation about AbstractSerializer's handling of relationship
Browse files Browse the repository at this point in the history
names.
  • Loading branch information
tobyzerner committed Mar 5, 2017
1 parent 78e908f commit 9eb6173
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ public function comments($post)
}
```

By default, the `AbstractSerializer` will convert relationship names from `kebab-case` and `snake_case` into a `camelCase` method name and call that on the serializer. If you wish to customize this behaviour, you may override the `getRelationship` method:

```php
public function getRelationship($model, $name)
{
// resolve Relationship called $name for $model
}
```

### Meta & Links

The `Document`, `Resource`, and `Relationship` classes allow you to add meta information:
Expand Down
3 changes: 1 addition & 2 deletions src/AbstractSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ public function getRelationship($model, $name)
/**
* Get the serializer method name for the given relationship.
*
*
* underscore, kebab-case is converted into camelCase.
* snake_case and kebab-case are converted into camelCase.
*
* @param string $name
*
Expand Down

0 comments on commit 9eb6173

Please sign in to comment.