[ENTITY][Note] Add getter for note links

This commit is contained in:
Diogo Peralta Cordeiro 2021-08-14 15:07:51 +01:00
parent c381e58d33
commit 4c1fc40c43
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
1 changed files with 12 additions and 0 deletions

View File

@ -223,6 +223,18 @@ class Note extends Entity
});
}
public function getLinks(): array
{
return Cache::get('note-links-' . $this->id, function () {
return DB::dql(
'select l from App\Entity\Link l ' .
'join App\Entity\NoteToLink ntl with ntl.link_id = l.id ' .
'where ntl.note_id = :note_id',
['note_id' => $this->id]
);
});
}
public function getReplies(): array
{
return Cache::getList('note-replies-' . $this->id, function () {