send system notification on period confirmation

This commit is contained in:
2021-12-30 02:10:35 +01:00
parent 7bc4ad9779
commit 5bf1b9d8bd
12 changed files with 233 additions and 23 deletions

View File

@@ -74,9 +74,14 @@ class Notification implements TrackUpdateInterface
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumn(nullable=false)
* @ORM\JoinColumn(nullable=true)
*/
private User $sender;
private ?User $sender = null;
/**
* @ORM\Column(type="text", options={"default": ""})
*/
private string $title = '';
/**
* @ORM\ManyToMany(targetEntity=User::class)
@@ -179,6 +184,11 @@ class Notification implements TrackUpdateInterface
return $this->sender;
}
public function getTitle(): string
{
return $this->title;
}
public function getUnreadBy(): Collection
{
return $this->unreadBy;
@@ -199,6 +209,11 @@ class Notification implements TrackUpdateInterface
return !$this->unreadBy->contains($user);
}
public function isSystem(): bool
{
return null === $this->sender;
}
public function markAsReadBy(User $user): self
{
return $this->removeUnreadBy($user);
@@ -299,6 +314,13 @@ class Notification implements TrackUpdateInterface
return $this;
}
public function setTitle(string $title): Notification
{
$this->title = $title;
return $this;
}
public function setUpdatedAt(DateTimeInterface $datetime): self
{
$this->updatedAt = $datetime;