diff --git a/CHANGELOG.md b/CHANGELOG.md index c6e1924..ada4831 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All Notable changes to `json-api-server` will be documented in this file. Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles. +## Unreleased + +### Fixed + +- Extra check so that uncountable data is not counted when getting relationships (Issue #20, thanks @bondas83) + ## 0.3.4 ### Fixed diff --git a/src/Http/Resources/BaseApiResource.php b/src/Http/Resources/BaseApiResource.php index 037db40..86f1422 100644 --- a/src/Http/Resources/BaseApiResource.php +++ b/src/Http/Resources/BaseApiResource.php @@ -165,7 +165,7 @@ protected function relationships() } $data = $this->resource->$relationship; - if (0 == count($data)) { + if ((is_array($data) || $data instanceof \Countable) && 0 == count($data)) { continue; }