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']) {