From 9eb6173af0d32305712cfeae12f9728e4782d7cb Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Sun, 5 Mar 2017 17:11:16 +1030 Subject: [PATCH] Add documentation about AbstractSerializer's handling of relationship names. --- README.md | 9 +++++++++ src/AbstractSerializer.php | 3 +-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 974d612..311cdda 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/src/AbstractSerializer.php b/src/AbstractSerializer.php index c5055fe..6e343cc 100644 --- a/src/AbstractSerializer.php +++ b/src/AbstractSerializer.php @@ -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 *