src/Entity/Notification.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\NotificationRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use DateTime;
  8. /**
  9.  * @ORM\Entity(repositoryClass=NotificationRepository::class)
  10.  * @ORM\HasLifecycleCallbacks()
  11.  */
  12. class Notification
  13. {
  14.     public const LEVEL_INFO 1;
  15.     public const LEVEL_SUCCESS 2;
  16.     public const LEVEL_WARNING 3;
  17.     public const LEVEL_ERROR 99;
  18.     /**
  19.      * @ORM\Id
  20.      * @ORM\GeneratedValue
  21.      * @ORM\Column(type="integer")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @ORM\Column(type="string", length=255, nullable=true)
  26.      */
  27.     private $title;
  28.     /**
  29.      * @ORM\Column(type="text")
  30.      */
  31.     private $content;
  32.     /**
  33.      * @ORM\Column(type="smallint")
  34.      */
  35.     private $level;
  36.     /**
  37.      * @ORM\OneToMany(targetEntity=UserNotification::class, mappedBy="notification", cascade={"persist"})
  38.      */
  39.     private $userNotifications;
  40.     /**
  41.      * @ORM\Column(type="datetime")
  42.      */
  43.     private $createdAt;
  44.     /**
  45.      * @ORM\Column(type="datetime", nullable=true)
  46.      */
  47.     private $updatedAt;
  48.     /**
  49.      * @ORM\Column(type="string", length=255)
  50.      */
  51.     private $uid;
  52.     /**
  53.      * @ORM\Column(type="boolean")
  54.      */
  55.     private $isTreated false;
  56.     /**
  57.      * @ORM\ManyToOne(targetEntity=User::class)
  58.      */
  59.     private $treatedBy;
  60.     /**
  61.      * @ORM\ManyToOne(targetEntity=Job::class, inversedBy="notifications")
  62.      */
  63.     private $job;
  64.     /**
  65.      * @ORM\Column(type="integer", nullable=true)
  66.      */
  67.     private $step;
  68.     public function __construct()
  69.     {
  70.         $this->userNotifications = new ArrayCollection();
  71.         $this->createdAt = new DateTime();
  72.     }
  73.     /**
  74.      * @ORM\PreUpdate()
  75.      */
  76.     public function preUpdateAt()
  77.     {
  78.         $this->updatedAt = new DateTime();
  79.     }
  80.     public function getId(): ?int
  81.     {
  82.         return $this->id;
  83.     }
  84.     public function getTitle(): ?string
  85.     {
  86.         return $this->title;
  87.     }
  88.     /**
  89.      * @param string|null $title
  90.      * @return $this
  91.      */
  92.     public function setTitle(?string $title): self
  93.     {
  94.         $this->title $title;
  95.         return $this;
  96.     }
  97.     public function getContent(): ?string
  98.     {
  99.         return $this->content;
  100.     }
  101.     public function setContent(string $content): self
  102.     {
  103.         $this->content $content;
  104.         return $this;
  105.     }
  106.     public function getLevel(): ?int
  107.     {
  108.         return $this->level;
  109.     }
  110.     public function setLevel(int $level): self
  111.     {
  112.         $this->level $level;
  113.         return $this;
  114.     }
  115.     /**
  116.      * @return Collection|UserNotification[]
  117.      */
  118.     public function getUserNotifications(): Collection
  119.     {
  120.         return $this->userNotifications;
  121.     }
  122.     public function addUserNotification(UserNotification $userNotification): self
  123.     {
  124.         if (!$this->userNotifications->contains($userNotification)) {
  125.             $this->userNotifications[] = $userNotification;
  126.             $userNotification->setNotification($this);
  127.         }
  128.         return $this;
  129.     }
  130.     public function removeUserNotification(UserNotification $userNotification): self
  131.     {
  132.         if ($this->userNotifications->removeElement($userNotification)) {
  133.             // set the owning side to null (unless already changed)
  134.             if ($userNotification->getNotification() === $this) {
  135.                 $userNotification->setNotification(null);
  136.             }
  137.         }
  138.         return $this;
  139.     }
  140.     public function getCreatedAt(): ?DateTime
  141.     {
  142.         return $this->createdAt;
  143.     }
  144.     public function setCreatedAt(DateTime $createdAt): self
  145.     {
  146.         $this->createdAt $createdAt;
  147.         return $this;
  148.     }
  149.     public function getUpdatedAt(): ?DateTime
  150.     {
  151.         return $this->updatedAt;
  152.     }
  153.     public function setUpdatedAt(?DateTime $updatedAt): self
  154.     {
  155.         $this->updatedAt $updatedAt;
  156.         return $this;
  157.     }
  158.     public function getUid(): ?string
  159.     {
  160.         return $this->uid;
  161.     }
  162.     public function setUid(string $uid): self
  163.     {
  164.         $this->uid $uid;
  165.         return $this;
  166.     }
  167.     public function getIsTreated(): ?bool
  168.     {
  169.         return $this->isTreated;
  170.     }
  171.     public function setIsTreated(bool $isTreated): self
  172.     {
  173.         $this->isTreated $isTreated;
  174.         return $this;
  175.     }
  176.     public function getTreatedBy(): ?User
  177.     {
  178.         return $this->treatedBy;
  179.     }
  180.     public function setTreatedBy(?User $treatedBy): self
  181.     {
  182.         $this->treatedBy $treatedBy;
  183.         return $this;
  184.     }
  185.     public function getJob(): ?Job
  186.     {
  187.         return $this->job;
  188.     }
  189.     public function setJob(?Job $job): self
  190.     {
  191.         $this->job $job;
  192.         return $this;
  193.     }
  194.     public function getStep(): ?int
  195.     {
  196.         return $this->step;
  197.     }
  198.     public function setStep(?int $step): self
  199.     {
  200.         $this->step $step;
  201.         return $this;
  202.     }
  203. }