feat: Add createdAt and updatedAt to Note entity

This commit is contained in:
Dendy 2025-02-06 15:49:33 +09:00
parent a0beb36a01
commit 230f5f18a1
1 changed files with 15 additions and 3 deletions

View File

@ -13,6 +13,7 @@ class Note
//#[ORM\Column]
private int $id;
private int $mod;
private array $terms = [];
const HIGHLIGHT_PATTERN = '/<span\s+([^>]*)>(.*?)<\/span>/i';
@ -38,7 +39,7 @@ class Note
{
$note = new self();
$note->id = $noteInfo['noteId'];
['noteId' => $note->id, 'mod' => $note->mod] = $noteInfo;
$fields = array_map(fn($x) => $x['value'], $noteInfo['fields']);
@ -120,6 +121,17 @@ class Note
return $terms;
}
public function getCreatedAt(): \DateTimeImmutable
{
$timestamp = ceil($this->id / 1000);
return \DateTimeImmutable::createFromFormat('U', $timestamp);
}
public function getUpdatedAt(): \DateTimeImmutable
{
return \DateTimeImmutable::createFromFormat('U', $this->mod);
}
}
class Term