From 0de6490af54c1c1906e165d265802e4a3064d6a1 Mon Sep 17 00:00:00 2001 From: Toon Van den Bos Date: Thu, 4 Apr 2019 21:48:32 +0200 Subject: [PATCH] Updated Resolver code formatting. Closes #9 --- src/Value/Resolver.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Value/Resolver.php b/src/Value/Resolver.php index ace5791f..c2bf4453 100644 --- a/src/Value/Resolver.php +++ b/src/Value/Resolver.php @@ -55,8 +55,11 @@ public function get($resource, $attribute, $layouts) protected function extractValueFromResource($resource, $attribute) { $value = data_get($resource, str_replace('->', '.', $attribute)) ?? []; + if (is_string($value)) $value = json_decode($value) ?? []; - if (!is_array($value)) return []; // Fail silently in case data is invalid + + // Fail silently in case data is invalid + if (!is_array($value)) return []; return array_map(function($item) { return is_array($item) ? (object) $item : $item;