src/Entity/Announcement.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AnnouncementRepository;
  4. use App\Traits\TimeStampTrait;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassAnnouncementRepository::class)]
  9. #[ORM\HasLifecycleCallbacks]
  10. class Announcement
  11. {
  12.     use TimeStampTrait;
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column(length100)]
  18.     private ?string $code null;
  19.     #[ORM\Column(length255)]
  20.     private ?string $title null;
  21.     #[ORM\Column(type'text')]
  22.     private ?string $message null;
  23.     #[ORM\Column(nullabletrue)]
  24.     private ?\DateTimeImmutable $sendAt null;
  25.     #[ORM\ManyToMany(targetEntityLocataire::class, inversedBy'announcements')]
  26.     private Collection $locataire;
  27.     #[ORM\ManyToMany(targetEntityUser::class, inversedBy'announcements')]
  28.     private Collection $user;
  29.     #[ORM\ManyToOne(inversedBy'announcements')]
  30.     private ?Entreprise $entreprise null;
  31.     #[ORM\Column]
  32.     private ?bool $view null;
  33.     #[ORM\Column]
  34.     private ?bool $sent null;
  35.     #[ORM\Column(length50nullabletrue)]
  36.     private ?string $type null;
  37.     #[ORM\OneToMany(mappedBy'annoucement'targetEntityNotificationView::class)]
  38.     private Collection $notificationViews;
  39.     public function __construct()
  40.     {
  41.         $this->locataire = new ArrayCollection();
  42.         $this->user = new ArrayCollection();
  43.         $this->notificationViews = new ArrayCollection();
  44.     }
  45.     public function getId(): ?int
  46.     {
  47.         return $this->id;
  48.     }
  49.     public function getCode(): ?string
  50.     {
  51.         return $this->code;
  52.     }
  53.     public function setCode(string $code): static
  54.     {
  55.         $this->code $code;
  56.         return $this;
  57.     }
  58.     public function getTitle(): ?string
  59.     {
  60.         return $this->title;
  61.     }
  62.     public function setTitle(string $title): static
  63.     {
  64.         $this->title $title;
  65.         return $this;
  66.     }
  67.     public function getMessage(): ?string
  68.     {
  69.         return $this->message;
  70.     }
  71.     public function setMessage(string $message): static
  72.     {
  73.         $this->message $message;
  74.         return $this;
  75.     }
  76.     public function getSendAt(): ?\DateTimeImmutable
  77.     {
  78.         return $this->sendAt;
  79.     }
  80.     public function setSendAt(?\DateTimeImmutable $sendAt): static
  81.     {
  82.         $this->sendAt $sendAt;
  83.         return $this;
  84.     }
  85.     /**
  86.      * @return Collection<int, Locataire>
  87.      */
  88.     public function getLocataire(): Collection
  89.     {
  90.         return $this->locataire;
  91.     }
  92.     public function addLocataire(Locataire $locataire): static
  93.     {
  94.         if (!$this->locataire->contains($locataire)) {
  95.             $this->locataire->add($locataire);
  96.         }
  97.         return $this;
  98.     }
  99.     public function removeLocataire(Locataire $locataire): static
  100.     {
  101.         $this->locataire->removeElement($locataire);
  102.         return $this;
  103.     }
  104.     /**
  105.      * @return Collection<int, User>
  106.      */
  107.     public function getUser(): Collection
  108.     {
  109.         return $this->user;
  110.     }
  111.     public function addUser(User $user): static
  112.     {
  113.         if (!$this->user->contains($user)) {
  114.             $this->user->add($user);
  115.         }
  116.         return $this;
  117.     }
  118.     public function removeUser(User $user): static
  119.     {
  120.         $this->user->removeElement($user);
  121.         return $this;
  122.     }
  123.     public function getEntreprise(): ?Entreprise
  124.     {
  125.         return $this->entreprise;
  126.     }
  127.     public function setEntreprise(?Entreprise $entreprise): static
  128.     {
  129.         $this->entreprise $entreprise;
  130.         return $this;
  131.     }
  132.     public function isView(): ?bool
  133.     {
  134.         return $this->view;
  135.     }
  136.     public function setView(bool $view): static
  137.     {
  138.         $this->view $view;
  139.         return $this;
  140.     }
  141.     public function isSent(): ?bool
  142.     {
  143.         return $this->sent;
  144.     }
  145.     public function setSent(bool $sent): static
  146.     {
  147.         $this->sent $sent;
  148.         return $this;
  149.     }
  150.     public function getType(): ?string
  151.     {
  152.         return $this->type;
  153.     }
  154.     public function setType(?string $type): static
  155.     {
  156.         $this->type $type;
  157.         return $this;
  158.     }
  159.     /**
  160.      * @return Collection<int, NotificationView>
  161.      */
  162.     public function getNotificationViews(): Collection
  163.     {
  164.         return $this->notificationViews;
  165.     }
  166.     public function addNotificationView(NotificationView $notificationView): static
  167.     {
  168.         if (!$this->notificationViews->contains($notificationView)) {
  169.             $this->notificationViews->add($notificationView);
  170.             $notificationView->setAnnoucement($this);
  171.         }
  172.         return $this;
  173.     }
  174.     public function removeNotificationView(NotificationView $notificationView): static
  175.     {
  176.         if ($this->notificationViews->removeElement($notificationView)) {
  177.             // set the owning side to null (unless already changed)
  178.             if ($notificationView->getAnnoucement() === $this) {
  179.                 $notificationView->setAnnoucement(null);
  180.             }
  181.         }
  182.         return $this;
  183.     }
  184. }