Simplify now that keys are fixed

This commit is contained in:
Lance Pioch 2024-05-21 21:48:16 -04:00
parent a9e58bb493
commit eadaec1b30

View File

@ -23,18 +23,13 @@ class NodeTransformer extends BaseTransformer
} }
/** /**
* Return a node transformed into a format that can be consumed by the * Return a node transformed into a format that can be consumed by the external administrative API.
* external administrative API.
*/ */
public function transform(Node $node): array public function transform(Node $node): array
{ {
$response = collect($node->toArray())->mapWithKeys(function ($value, $key) { $response = collect($node->toArray())
// I messed up early in 2016 when I named this column as poorly ->mapWithKeys(fn ($value, $key) => [snake_case($key) => $value])
// as I did. This is the tragic result of my mistakes. ->toArray();
$key = ($key === 'daemon_sftp') ? 'daemon_sftp' : $key;
return [snake_case($key) => $value];
})->toArray();
$response[$node->getUpdatedAtColumn()] = $this->formatTimestamp($node->updated_at); $response[$node->getUpdatedAtColumn()] = $this->formatTimestamp($node->updated_at);
$response[$node->getCreatedAtColumn()] = $this->formatTimestamp($node->created_at); $response[$node->getCreatedAtColumn()] = $this->formatTimestamp($node->created_at);