src/Entity/Menu.php line 15

Open in your IDE?
  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\ORM\Mapping as ORM;
  7. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. #[ORM\Entity(repositoryClassMenuRepository::class)]
  11. #[Vich\Uploadable]
  12. class Menu
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     private ?int $id null;
  18.     #[ORM\Column(length255)]
  19.     #[Assert\NotBlank(message'Le nom du menu est obligatoire')]
  20.     #[Assert\Length(min2max255minMessage'Le nom doit faire au moins {{ limit }} caractères'maxMessage'Le nom ne peut pas dépasser {{ limit }} caractères')]
  21.     private ?string $nom null;
  22.     #[ORM\Column(length255nullabletrue)]
  23.     #[Assert\Length(max255maxMessage'La description ne peut pas dépasser {{ limit }} caractères')]
  24.     private ?string $description null;
  25.     #[ORM\OneToMany(targetEntityMenuProduit::class, mappedBy"menu"cascade: ["persist""remove"], orphanRemovaltrue)]
  26.     private Collection $menuProduit
  27.     #[ORM\Column(nullabletrue)]
  28.     private ?\DateTimeImmutable $updatedAt null;
  29.     #[ORM\Column(nullabletrue)]
  30.     private ?string $imageName null;
  31.     #[Vich\UploadableField(mapping'menu'fileNameProperty'imageName')]
  32.     private ?File $imageFile null;
  33.     #[ORM\Column]
  34.     #[Assert\NotBlank(message'Le prix est obligatoire')]
  35.     #[Assert\PositiveOrZero(message'Le prix doit être positif ou zéro')]
  36.     private ?int $prix null;
  37.     #[ORM\OneToMany(mappedBy'menu'targetEntityDetailsVente::class, orphanRemovalfalse)]
  38.     private Collection $detailsVentes;
  39.     public function __construct()
  40.     {
  41.         $this->menuProduit = new ArrayCollection(); // Initialize the collection
  42.         $this->detailsVentes = new ArrayCollection();
  43.     }
  44.     // Other getter and setter methods...
  45.     public function getId(): ?int
  46.     {
  47.         return $this->id;
  48.     }
  49.     public function getNom(): ?string
  50.     {
  51.         return $this->nom;
  52.     }
  53.     public function setNom(string $nom): static
  54.     {
  55.         $this->nom $nom;
  56.         return $this;
  57.     }
  58.     public function getDescription(): ?string
  59.     {
  60.         return $this->description;
  61.     }
  62.     public function setDescription(string $description): static
  63.     {
  64.         $this->description $description;
  65.         return $this;
  66.     }
  67.     /**
  68.      * @return Collection<int, MenuProduit>
  69.      */
  70.     public function getMenuProduit(): Collection
  71.     {
  72.         return $this->menuProduit;
  73.     }
  74.     public function addMenuProduit(MenuProduit $menuProduit): static
  75.     {
  76.         if (!$this->menuProduit->contains($menuProduit)) {
  77.             $this->menuProduit->add($menuProduit);
  78.             $menuProduit->setMenu($this);
  79.         }
  80.         return $this;
  81.     }
  82.     public function removeMenuProduit(MenuProduit $menuProduit): static
  83.     {
  84.         if ($this->menuProduit->removeElement($menuProduit)) {
  85.             // set the owning side to null (unless already changed)
  86.             if ($menuProduit->getMenu() === $this) {
  87.                 $menuProduit->setMenu(null);
  88.             }
  89.         }
  90.         return $this;
  91.     }
  92.     public function setImageFile(?File $imageFile null): void
  93.     {
  94.         $this->imageFile $imageFile;
  95.         if (null !== $imageFile) {
  96.             $this->updatedAt = new \DateTimeImmutable('now');
  97.         }
  98.     }
  99.     public function getImageFile(): ?File
  100.     {
  101.         return $this->imageFile;
  102.     }
  103.     public function setImageName(?string $imageName): void
  104.     {
  105.         $this->imageName $imageName;
  106.     }
  107.     public function getImageName(): ?string
  108.     {
  109.         return $this->imageName;
  110.     }
  111.     public function getPrix(): ?int
  112.     {
  113.         return $this->prix;
  114.     }
  115.     public function setPrix(int $prix): static
  116.     {
  117.         $this->prix $prix;
  118.         return $this;
  119.     }
  120.     /**
  121.      * @return Collection<int, DetailsVente>
  122.      */
  123.     public function getDetailsVentes(): Collection
  124.     {
  125.         return $this->detailsVentes;
  126.     }
  127.     public function addDetailsVente(DetailsVente $detailsVente): static
  128.     {
  129.         if (!$this->detailsVentes->contains($detailsVente)) {
  130.             $this->detailsVentes->add($detailsVente);
  131.             $detailsVente->setMenu($this);
  132.         }
  133.         return $this;
  134.     }
  135.     public function removeDetailsVente(DetailsVente $detailsVente): static
  136.     {
  137.         if ($this->detailsVentes->removeElement($detailsVente)) {
  138.             // set the owning side to null (unless already changed)
  139.             if ($detailsVente->getMenu() === $this) {
  140.                 $detailsVente->setMenu(null);
  141.             }
  142.         }
  143.         return $this;
  144.     }
  145. }