mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-19 03:32:51 +00:00
notificaton: add comments
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user