feat: Add createdAt and updatedAt to Note entity
This commit is contained in:
		
							parent
							
								
									a0beb36a01
								
							
						
					
					
						commit
						230f5f18a1
					
				|  | @ -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 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue