From 942b8d0b49a3f156ce5d39e42404f1ee878056ee Mon Sep 17 00:00:00 2001 From: Craig Paul Date: Tue, 25 Oct 2016 19:42:36 -0600 Subject: [PATCH] Adds extra normalization steps to prepare --- src/Preparable.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Preparable.php b/src/Preparable.php index 06a587a..71292c8 100644 --- a/src/Preparable.php +++ b/src/Preparable.php @@ -19,7 +19,11 @@ protected function prepare($data, array $params) $key = $param['key']; $property = $param['property']; - $array[$property] = isset($data->$key) && !is_null($data->$key) ? $data->$key : null; + if (is_array($data)) { + $array[$property] = isset($data[$key]) && !is_null($data[$key]) ? $data[$key] : null; + } else { + $array[$property] = isset($data->$key) && !is_null($data->$key) ? $data->$key : null; + } if (isset($param['cast'])) { switch ($param['cast']) {