<?phpnamespace App\Entity\Gos;use App\Repository\Gos\UserNotificationRepository;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity(repositoryClass=UserNotificationRepository::class) * @ORM\HasLifecycleCallbacks() */class UserNotification{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=255, nullable=true) */ private $title; /** * @ORM\Column(type="text", nullable=true) */ private $message; /** * @ORM\ManyToOne(targetEntity="User", inversedBy="userNotification", cascade={"persist"}) * @ORM\JoinColumn(nullable=false) */ private $user; /** * @ORM\ManyToOne(targetEntity=PortalSettings::class) */ private $portalSettings; /** * @ORM\ManyToOne(targetEntity="NotificationForUser", inversedBy="userNotification", cascade={"persist"}) * @ORM\JoinColumn(nullable=true) */ private $notificationForUser; /** * @ORM\Column(type="datetime", nullable=true) */ private $readAt; /** * @ORM\Column(type="datetime") */ private $createdAt; /** @ORM\PrePersist() */ public function onPrePersist() { $this->createdAt = new \DateTime(); } public function getId(): ?int { return $this->id; } public function getTitle(): ?string { if (empty($this->title) && $this->getNotificationForUser() !== null) { return $this->getNotificationForUser()->getName(); } return $this->title; } public function setTitle(?string $title): self { $this->title = $title; return $this; } public function getMessage(): ?string { if (empty($this->message) && $this->getNotificationForUser() !== null) { return $this->getNotificationForUser()->getMessage(); } return $this->message; } public function setMessage(?string $message): self { $this->message = $message; return $this; } public function getUser(): ?User { return $this->user; } public function setUser(?User $user): self { $this->user = $user; return $this; } public function getPortalSettings(): ?PortalSettings { return $this->portalSettings; } public function setPortalSettings(?PortalSettings $portalSettings): self { $this->portalSettings = $portalSettings; return $this; } public function getNotificationForUser(): ?NotificationForUser { return $this->notificationForUser; } public function setNotificationForUser(?NotificationForUser $notificationForUser): self { $this->notificationForUser = $notificationForUser; return $this; } public function getReadAt(): ?\DateTimeInterface { return $this->readAt; } public function setReadAt(?\DateTimeInterface $readAt): self { $this->readAt = $readAt; return $this; } public function getCreatedAt(): ?\DateTimeInterface { return $this->createdAt; } public function setCreatedAt(\DateTimeInterface $createdAt): self { $this->createdAt = $createdAt; return $this; }}