src/Entity/Menu.php line 15

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\MenuRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use Symfony\Component\Uid\Uuid;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. #[ORM\Entity(repositoryClassMenuRepository::class)]
  12. class Menu
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\Column(type'uuid'uniquetrue)]
  16.     #[Groups(['BASE'])]
  17.     private ?string $id null;
  18.     #[ORM\Column(length255)]
  19.     private ?string $name null;
  20.     #[ORM\ManyToOne(inversedBy'menus')]
  21.     #[ORM\JoinColumn(nullablefalse)]
  22.     private ?Whitelabel $whitelabel null;
  23.     #[ORM\ManyToOne(inversedBy'menus')]
  24.     #[ORM\JoinColumn(nullablefalse)]
  25.     private ?User $creatorUser null;
  26.     #[ORM\ManyToOne(inversedBy'menus')]
  27.     #[ORM\JoinColumn(nullabletrue)]
  28.     private ?Property $property null;
  29.     #[ORM\Column(length255nullabletrue)]
  30.     private ?string $templateName null;
  31.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  32.     private ?\DateTimeInterface $createDate null;
  33.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  34.     private ?\DateTimeInterface $fromDate null;
  35.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  36.     private ?\DateTimeInterface $toDate null;
  37.     #[ORM\ManyToMany(targetEntityProduct::class, inversedBy'menus')]
  38.     private Collection $products;
  39.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  40.     private ?\DateTimeInterface $sendNotificationDate null;
  41.     #[ORM\OneToMany(mappedBy'menu'targetEntityNotificationHistory::class, orphanRemovaltrue)]
  42.     private Collection $notificationHistories;
  43.     #[ORM\ManyToMany(targetEntityFile::class, inversedBy'menus')]
  44.     private Collection $files;
  45.     #[Assert\Choice(choices: [\App\Repository\MenuRepository::TYPE_MENU_LUNCH\App\Repository\MenuRepository::TYPE_MENU_MAIN\App\Repository\MenuRepository::TYPE_MENU_CATERING], message'Choose a valid type.')]
  46.     #[ORM\Column(nullabletrue)]
  47.     private ?int $type null;
  48.     #[ORM\Column(options: ['default' => true])]
  49.     private bool $isPublished true;
  50.     public function __construct()
  51.     {
  52.         $this->id Uuid::v4();
  53.         $this->products = new ArrayCollection();
  54.         $this->notificationHistories = new ArrayCollection();
  55.         $this->files = new ArrayCollection();
  56.     }
  57.     public function getId(): ?string
  58.     {
  59.         return $this->id;
  60.     }
  61.     public function setId(string $id): self
  62.     {
  63.         $this->id $id;
  64.         return $this;
  65.     }
  66.     public function getName(): ?string
  67.     {
  68.         return $this->name;
  69.     }
  70.     public function setName(string $name): self
  71.     {
  72.         $this->name $name;
  73.         return $this;
  74.     }
  75.     public function getTemplateName(): ?string
  76.     {
  77.         return $this->templateName;
  78.     }
  79.     public function setTemplateName(string $templateName): self
  80.     {
  81.         $this->templateName $templateName;
  82.         return $this;
  83.     }
  84.     public function getType(): ?int
  85.     {
  86.         return $this->type;
  87.     }
  88.     public function setType(int $type): self
  89.     {
  90.         $this->type $type;
  91.         return $this;
  92.     }
  93.     public function getWhitelabel(): ?Whitelabel
  94.     {
  95.         return $this->whitelabel;
  96.     }
  97.     public function setWhitelabel(?Whitelabel $whitelabel): self
  98.     {
  99.         $this->whitelabel $whitelabel;
  100.         return $this;
  101.     }
  102.     public function getProperty(): ?Property
  103.     {
  104.         return $this->property;
  105.     }
  106.     public function setProperty(?Property $property): self
  107.     {
  108.         $this->property $property;
  109.         return $this;
  110.     }
  111.     public function getCreatorUser(): ?User
  112.     {
  113.         return $this->creatorUser;
  114.     }
  115.     public function setCreatorUser(?User $creatorUser): self
  116.     {
  117.         $this->creatorUser $creatorUser;
  118.         return $this;
  119.     }
  120.     public function getCreateDate(): ?\DateTimeInterface
  121.     {
  122.         return $this->createDate;
  123.     }
  124.     public function setCreateDate(\DateTimeInterface $createDate): self
  125.     {
  126.         $this->createDate $createDate;
  127.         return $this;
  128.     }
  129.     public function getFromDate(): ?\DateTimeInterface
  130.     {
  131.         return $this->fromDate;
  132.     }
  133.     public function setFromDate(?\DateTimeInterface $fromDate): self
  134.     {
  135.         $this->fromDate $fromDate;
  136.         return $this;
  137.     }
  138.     public function getToDate(): ?\DateTimeInterface
  139.     {
  140.         return $this->toDate;
  141.     }
  142.     public function setToDate(?\DateTimeInterface $toDate): self
  143.     {
  144.         $this->toDate $toDate;
  145.         return $this;
  146.     }
  147.     /**
  148.      * @return Collection<int, Product>
  149.      */
  150.     public function getProducts(): Collection
  151.     {
  152.         return $this->products;
  153.     }
  154.     public function addProduct(Product $product): self
  155.     {
  156.         if (!$this->products->contains($product)) {
  157.             $this->products->add($product);
  158.         }
  159.         return $this;
  160.     }
  161.     public function removeProduct(Product $product): self
  162.     {
  163.         $this->products->removeElement($product);
  164.         return $this;
  165.     }
  166.     public function getSendNotificationDate(): ?\DateTimeInterface
  167.     {
  168.         return $this->sendNotificationDate;
  169.     }
  170.     public function setSendNotificationDate(?\DateTimeInterface $sendNotificationDate): self
  171.     {
  172.         $this->sendNotificationDate $sendNotificationDate;
  173.         return $this;
  174.     }
  175.     /**
  176.      * @return Collection<int, NotificationHistory>
  177.      */
  178.     public function getNotificationHistories(): Collection
  179.     {
  180.         return $this->notificationHistories;
  181.     }
  182.     public function addNotificationHistory(NotificationHistory $notificationHistory): self
  183.     {
  184.         if (!$this->notificationHistories->contains($notificationHistory)) {
  185.             $this->notificationHistories->add($notificationHistory);
  186.             $notificationHistory->setMenu($this);
  187.         }
  188.         return $this;
  189.     }
  190.     public function removeNotificationHistory(NotificationHistory $notificationHistory): self
  191.     {
  192.         if ($this->notificationHistories->removeElement($notificationHistory)) {
  193.             // set the owning side to null (unless already changed)
  194.             if ($notificationHistory->getMenu() === $this) {
  195.                 $notificationHistory->setMenu(null);
  196.             }
  197.         }
  198.         return $this;
  199.     }
  200.     public function isIsPublished(): bool
  201.     {
  202.         return $this->isPublished;
  203.     }
  204.     public function setIsPublished(bool $isPublished): self
  205.     {
  206.         $this->isPublished $isPublished;
  207.         return $this;
  208.     }
  209.     /**
  210.      * @return Collection<int, File>
  211.      */
  212.     public function getFiles(): Collection
  213.     {
  214.         return $this->files;
  215.     }
  216.     public function addFile(File $file): static
  217.     {
  218.         if (!$this->files->contains($file)) {
  219.             $this->files->add($file);
  220.         }
  221.         return $this;
  222.     }
  223.     public function removeFile(File $file): static
  224.     {
  225.         $this->files->removeElement($file);
  226.         return $this;
  227.     }
  228. }