From 9e81e9f9550882d07ada5263491b09e480294d53 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Thu, 14 May 2015 22:35:31 +0930 Subject: [PATCH] Properly include to-many relations --- src/Api/Serializers/BaseSerializer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Api/Serializers/BaseSerializer.php b/src/Api/Serializers/BaseSerializer.php index 818f074e6..cbdf0effb 100644 --- a/src/Api/Serializers/BaseSerializer.php +++ b/src/Api/Serializers/BaseSerializer.php @@ -54,7 +54,7 @@ abstract class BaseSerializer extends SerializerAbstract $data = $relation($model, $include); } else { if ($include) { - $data = !is_null($model->$relation) ? $model->$relation : $model->$relation()->first(); + $data = !is_null($model->$relation) ? $model->$relation : ($many ? $model->$relation()->get() : $model->$relation()->first()); } elseif ($many) { $relationIds = $relation.'_ids'; $data = $model->$relationIds ?: $model->$relation()->get(['id'])->fetch('id')->all();