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

Commit 9eb6173

Browse files
committed
Add documentation about AbstractSerializer's handling of relationship
names.
1 parent 78e908f commit 9eb6173

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,15 @@ public function comments($post)
102102
}
103103
```
104104

105+
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:
106+
107+
```php
108+
public function getRelationship($model, $name)
109+
{
110+
// resolve Relationship called $name for $model
111+
}
112+
```
113+
105114
### Meta & Links
106115

107116
The `Document`, `Resource`, and `Relationship` classes allow you to add meta information:

src/AbstractSerializer.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ public function getRelationship($model, $name)
8585
/**
8686
* Get the serializer method name for the given relationship.
8787
*
88-
*
89-
* underscore, kebab-case is converted into camelCase.
88+
* snake_case and kebab-case are converted into camelCase.
9089
*
9190
* @param string $name
9291
*

0 commit comments

Comments
 (0)