diff --git a/composer.json b/composer.json index 28b1b0d851..86d973047e 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,8 @@ "larapack/doctrine-support": "~0.1.4", "arrilot/laravel-widgets": "^3.7", "league/flysystem": "~1.0.41", - "larapack/voyager-hooks": "~1.0.5" + "larapack/voyager-hooks": "~1.0.5", + "ext-json": "*" }, "require-dev": { "phpunit/phpcov": "~3.0|~4.0", diff --git a/src/Translator.php b/src/Translator.php index 28e7ffdfcc..e0feb6a588 100644 --- a/src/Translator.php +++ b/src/Translator.php @@ -4,9 +4,10 @@ use ArrayAccess; use Illuminate\Database\Eloquent\Model; +use JsonSerializable; use TCG\Voyager\Facades\Voyager as VoyagerFacade; -class Translator implements ArrayAccess +class Translator implements ArrayAccess, JsonSerializable { protected $model; protected $attributes = []; @@ -316,4 +317,11 @@ public function runTranslatorMethod($method, array $arguments) return call_user_func_array([$this->model, $method], $arguments); } + + public function jsonSerialize() + { + return array_map(function ($array) { + return $array['value']; + }, $this->getRawAttributes()); + } }