From 728f8d8fb8adfa95b020288f2525fde4beb22d83 Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Sat, 14 Aug 2021 15:07:51 +0100 Subject: [PATCH] [ENTITY][Note] Add getter for note links --- src/Entity/Note.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Entity/Note.php b/src/Entity/Note.php index 9ccf439a44..0ebb455089 100644 --- a/src/Entity/Note.php +++ b/src/Entity/Note.php @@ -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 () {