src/Entity/Notification.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use DateTime;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\HttpFoundation\File\File;
  6. use Symfony\Component\HttpFoundation\File\UploadedFile;
  7. use Symfony\Component\Serializer\Annotation\Ignore;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. /**
  10.  * Notification
  11.  *
  12.  * @ORM\Table(name="notification")
  13.  * @ORM\Entity(repositoryClass="App\Repository\NotificationRepository")
  14.  */
  15. class Notification
  16. {
  17.     /**
  18.      * @ORM\Column(name="id", type="integer")
  19.      * @ORM\Id
  20.      * @ORM\GeneratedValue(strategy="AUTO")
  21.      */
  22.     private int $id;
  23.     /**
  24.      * @ORM\Column(name="reception_date", type="datetime", nullable=false)
  25.      */
  26.     private DateTime $receptionDate;
  27.     /**
  28.      * @ORM\Column(name="created_at", type="datetime")
  29.      */
  30.     private DateTime $createdAt;
  31.     /**
  32.      * @ORM\ManyToOne(targetEntity="App\Entity\Building", cascade={"persist"})
  33.      * @ORM\JoinColumns({
  34.      *   @ORM\JoinColumn(name="building_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  35.      * })
  36.      */
  37.     private Building $building;
  38.     /**
  39.      * @ORM\Column(name="title", type="string", length=255, nullable=true)
  40.      */
  41.     private string|null $title;
  42.     /**
  43.      * @ORM\Column(name="text", type="string", length=512, nullable=true)
  44.      */
  45.     private string|null $text;
  46.     /**
  47.      * @ORM\Column(name="status", type="integer", nullable=true)
  48.      */
  49.     private int|null $status;
  50.     /**
  51.      * @ORM\ManyToOne(targetEntity="App\Entity\User")
  52.      * @ORM\JoinColumns({
  53.      *   @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false)
  54.      * })
  55.      */
  56.     #[Ignore]
  57.     private User $user;
  58.     /**
  59.      * @ORM\Column(name="createdBy", type="string", nullable=true)
  60.      */
  61.     private string|null $createdBy;
  62.     /**
  63.      * @ORM\Column(name="publish_notification", type="boolean")
  64.      */
  65.     private bool $publish_notification false;
  66.     /**
  67.      * @ORM\Column(type="string", nullable=true)
  68.      *
  69.      * @Assert\File(mimeTypes={ "application/pdf" })
  70.      */
  71.     private UploadedFile|File|string|null $file null;
  72.     /**
  73.      * @ORM\Column(type="string", length=255, nullable=true)
  74.      */
  75.     private ?string $fileName null;
  76.     /**
  77.      * @return string|null
  78.      */
  79.     public function getCreatedBy(): ?string
  80.     {
  81.         return $this->createdBy;
  82.     }
  83.     /**
  84.      * @param string $createdBy
  85.      */
  86.     public function setCreatedBy(string $createdBy): void
  87.     {
  88.         $this->createdBy $createdBy;
  89.     }
  90.     /**
  91.      * @return int|null
  92.      */
  93.     public function getId(): ?int
  94.     {
  95.         return $this->id;
  96.     }
  97.     /**
  98.      * @return DateTime
  99.      */
  100.     public function getReceptionDate(): DateTime
  101.     {
  102.         return $this->receptionDate;
  103.     }
  104.     /**
  105.      * @param DateTime $receptionDate
  106.      */
  107.     public function setReceptionDate(DateTime $receptionDate): void
  108.     {
  109.         $this->receptionDate $receptionDate;
  110.     }
  111.     /**
  112.      * @return DateTime
  113.      */
  114.     public function getCreatedAt(): DateTime
  115.     {
  116.         return $this->createdAt;
  117.     }
  118.     /**
  119.      * @param DateTime $createdAt
  120.      */
  121.     public function setCreatedAt(DateTime $createdAt): void
  122.     {
  123.         $this->createdAt $createdAt;
  124.     }
  125.     /**
  126.      * @return Building
  127.      */
  128.     public function getBuilding(): Building
  129.     {
  130.         return $this->building;
  131.     }
  132.     /**
  133.      * @param Building $building
  134.      */
  135.     public function setBuilding(Building $building): void
  136.     {
  137.         $this->building $building;
  138.     }
  139.     /**
  140.      * @return string|null
  141.      */
  142.     public function getTitle(): ?string
  143.     {
  144.         return $this->title;
  145.     }
  146.     /**
  147.      * @param string $title
  148.      */
  149.     public function setTitle(string $title): void
  150.     {
  151.         $this->title $title;
  152.     }
  153.     /**
  154.      * @return string|null
  155.      */
  156.     public function getText(): ?string
  157.     {
  158.         return $this->text;
  159.     }
  160.     /**
  161.      * @param string $text
  162.      */
  163.     public function setText(string $text): void
  164.     {
  165.         $this->text $text;
  166.     }
  167.     /**
  168.      * @return int|null
  169.      */
  170.     public function getStatus(): ?int
  171.     {
  172.         return $this->status;
  173.     }
  174.     /**
  175.      * @param int $status
  176.      */
  177.     public function setStatus(int $status): void
  178.     {
  179.         $this->status $status;
  180.     }
  181.     /**
  182.      * @return User
  183.      */
  184.     #[Ignore]
  185.     public function getUser(): User
  186.     {
  187.         return $this->user;
  188.     }
  189.     /**
  190.      * @param User $user
  191.      */
  192.     #[Ignore]
  193.     public function setUser(User $user): void
  194.     {
  195.         $this->user $user;
  196.         if (empty($this->createdBy)) {
  197.             $this->createdBy $user->getCreatedByValue();
  198.         }
  199.     }
  200.     /**
  201.      * @return bool
  202.      */
  203.     public function isPublishNotification(): bool
  204.     {
  205.         return $this->publish_notification;
  206.     }
  207.     /**
  208.      * @param bool $publish_notification
  209.      */
  210.     public function setPublishNotification(bool $publish_notification): void
  211.     {
  212.         $this->publish_notification $publish_notification;
  213.     }
  214.     public function getFile(): File|string|UploadedFile|null
  215.     {
  216.         return $this->file;
  217.     }
  218.     public function setFile(File|string|UploadedFile|null $file): void
  219.     {
  220.         $this->file $file;
  221.     }
  222.     public function getFileName(): ?string
  223.     {
  224.         return $this->fileName;
  225.     }
  226.     public function setFileName(?string $fileName): void
  227.     {
  228.         $this->fileName $fileName;
  229.     }
  230. }