[ENTITY][Note] Add getter for note links

This commit is contained in:
Diogo Peralta Cordeiro 2021-08-14 15:07:51 +01:00 committed by Hugo Sales
parent 9e4cac0123
commit 728f8d8fb8
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0

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 () {