Skip to content

Commit

Permalink
traits/GetToFieldsTrait: Si se pide un campo DateTime se devuelve el …
Browse files Browse the repository at this point in the history
…timestamp de este
  • Loading branch information
ddniel16 committed May 27, 2020
1 parent d1fca76 commit 080091b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion traits/GetToFieldsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,16 @@ public function __getToFields(?string $fields = NULL): array

if (method_exists($this, $getter)) {
$data = $this->$getter();

if (is_null($data) && empty($data)) {
$item[$key] = $data;
continue;
}

if($data instanceof \DateTime) {
$item[$key] = $data->getTimestamp();
continue;
}

if ($data instanceof PersistentCollection) {
$item[$key] = $this->_getEntityDateRelation($data, $value, true);
} elseif (
Expand Down

0 comments on commit 080091b

Please sign in to comment.