notificaton: add comments

This commit is contained in:
2021-12-28 23:03:58 +01:00
parent 1ad6a958e2
commit 9647785d8b
3 changed files with 209 additions and 0 deletions

View File

@@ -35,6 +35,12 @@ class Notification
private ?ArrayCollection $addressesOnLoad = null;
/**
* @ORM\OneToMany(targetEntity=NotificationComment::class, mappedBy="notification", orphanRemoval=true)
* @ORM\OrderBy({"createdAt": "ASC"})
*/
private Collection $comments;
/**
* @ORM\Column(type="datetime_immutable")
*/
@@ -80,6 +86,7 @@ class Notification
{
$this->addressees = new ArrayCollection();
$this->unreadBy = new ArrayCollection();
$this->comments = new ArrayCollection();
$this->setDate(new DateTimeImmutable());
}
@@ -93,6 +100,16 @@ class Notification
return $this;
}
public function addComment(NotificationComment $comment): self
{
if (!$this->comments->contains($comment)) {
$this->comments[] = $comment;
$comment->setNotification($this);
}
return $this;
}
public function addUnreadBy(User $user): self
{
if (!$this->unreadBy->contains($user)) {
@@ -115,6 +132,11 @@ class Notification
return $this->addressees;
}
public function getComments(): Collection
{
return $this->comments;
}
public function getDate(): ?DateTimeImmutable
{
return $this->date;
@@ -192,6 +214,13 @@ class Notification
return $this;
}
public function removeComment(NotificationComment $comment): self
{
$this->comments->removeElement($comment);
return $this;
}
public function removeUnreadBy(User $user): self
{
$this->unreadBy->removeElement($user);