Ensure eggs endpoint always returns an object, even when empty
closes #4296
This commit is contained in:
parent
b050174f90
commit
bf2456d0fc
1 changed files with 6 additions and 1 deletions
|
@ -38,6 +38,11 @@ class EggTransformer extends BaseTransformer
|
||||||
*/
|
*/
|
||||||
public function transform(Egg $model)
|
public function transform(Egg $model)
|
||||||
{
|
{
|
||||||
|
$files = json_decode($model->config_files, true, 512, JSON_THROW_ON_ERROR);
|
||||||
|
if (empty($files)) {
|
||||||
|
$files = new \stdClass();
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => $model->id,
|
'id' => $model->id,
|
||||||
'uuid' => $model->uuid,
|
'uuid' => $model->uuid,
|
||||||
|
@ -51,7 +56,7 @@ class EggTransformer extends BaseTransformer
|
||||||
'docker_image' => count($model->docker_images) > 0 ? Arr::first($model->docker_images) : '',
|
'docker_image' => count($model->docker_images) > 0 ? Arr::first($model->docker_images) : '',
|
||||||
'docker_images' => $model->docker_images,
|
'docker_images' => $model->docker_images,
|
||||||
'config' => [
|
'config' => [
|
||||||
'files' => json_decode($model->config_files, true),
|
'files' => $files,
|
||||||
'startup' => json_decode($model->config_startup, true),
|
'startup' => json_decode($model->config_startup, true),
|
||||||
'stop' => $model->config_stop,
|
'stop' => $model->config_stop,
|
||||||
'logs' => json_decode($model->config_logs, true),
|
'logs' => json_decode($model->config_logs, true),
|
||||||
|
|
Loading…
Reference in a new issue