src/Entity/Gos/UserNotification.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gos;
  3. use App\Repository\Gos\UserNotificationRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * @ORM\Entity(repositoryClass=UserNotificationRepository::class)
  7.  * @ORM\HasLifecycleCallbacks()
  8.  */
  9. class UserNotification
  10. {
  11.     /**
  12.      * @ORM\Id
  13.      * @ORM\GeneratedValue
  14.      * @ORM\Column(type="integer")
  15.      */
  16.     private $id;
  17.     /**
  18.      * @ORM\Column(type="string", length=255, nullable=true)
  19.      */
  20.     private $title;
  21.     /**
  22.      * @ORM\Column(type="text", nullable=true)
  23.      */
  24.     private $message;
  25.     /**
  26.      * @ORM\ManyToOne(targetEntity="User", inversedBy="userNotification", cascade={"persist"})
  27.      * @ORM\JoinColumn(nullable=false)
  28.      */
  29.     private $user;
  30.     /**
  31.      * @ORM\ManyToOne(targetEntity=PortalSettings::class)
  32.      */
  33.     private $portalSettings;
  34.     /**
  35.      * @ORM\ManyToOne(targetEntity="NotificationForUser", inversedBy="userNotification", cascade={"persist"})
  36.      * @ORM\JoinColumn(nullable=true)
  37.      */
  38.     private $notificationForUser;
  39.     /**
  40.      * @ORM\Column(type="datetime", nullable=true)
  41.      */
  42.     private $readAt;
  43.     /**
  44.      * @ORM\Column(type="datetime")
  45.      */
  46.     private $createdAt;
  47.     /** @ORM\PrePersist() */
  48.     public function onPrePersist()
  49.     {
  50.         $this->createdAt = new \DateTime();
  51.     }
  52.     public function getId(): ?int
  53.     {
  54.         return $this->id;
  55.     }
  56.     public function getTitle(): ?string
  57.     {
  58.         if (empty($this->title) && $this->getNotificationForUser() !== null)
  59.         {
  60.             return $this->getNotificationForUser()->getName();
  61.         }
  62.         return $this->title;
  63.     }
  64.     public function setTitle(?string $title): self
  65.     {
  66.         $this->title $title;
  67.         return $this;
  68.     }
  69.     public function getMessage(): ?string
  70.     {
  71.         if (empty($this->message) && $this->getNotificationForUser() !== null)
  72.         {
  73.             return $this->getNotificationForUser()->getMessage();
  74.         }
  75.         return $this->message;
  76.     }
  77.     public function setMessage(?string $message): self
  78.     {
  79.         $this->message $message;
  80.         return $this;
  81.     }
  82.     public function getUser(): ?User
  83.     {
  84.         return $this->user;
  85.     }
  86.     public function setUser(?User $user): self
  87.     {
  88.         $this->user $user;
  89.         return $this;
  90.     }
  91.     public function getPortalSettings(): ?PortalSettings
  92.     {
  93.         return $this->portalSettings;
  94.     }
  95.     public function setPortalSettings(?PortalSettings $portalSettings): self
  96.     {
  97.         $this->portalSettings $portalSettings;
  98.         return $this;
  99.     }
  100.     public function getNotificationForUser(): ?NotificationForUser
  101.     {
  102.         return $this->notificationForUser;
  103.     }
  104.     public function setNotificationForUser(?NotificationForUser $notificationForUser): self
  105.     {
  106.         $this->notificationForUser $notificationForUser;
  107.         return $this;
  108.     }
  109.     public function getReadAt(): ?\DateTimeInterface
  110.     {
  111.         return $this->readAt;
  112.     }
  113.     public function setReadAt(?\DateTimeInterface $readAt): self
  114.     {
  115.         $this->readAt $readAt;
  116.         return $this;
  117.     }
  118.     public function getCreatedAt(): ?\DateTimeInterface
  119.     {
  120.         return $this->createdAt;
  121.     }
  122.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  123.     {
  124.         $this->createdAt $createdAt;
  125.         return $this;
  126.     }
  127. }