src\Entity\Menu.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. use App\Repository\MenuRepository;
  8. #[ORM\Entity(repositoryClass: MenuRepository::class)]
  9. #[ORM\Table(name: '`menu`')]
  10. #[UniqueEntity(fields: ['titre'], message: 'Le titre existe déjà')]
  11. class Menu
  12. {
  13. #[ORM\Id]
  14. #[ORM\GeneratedValue]
  15. #[ORM\Column]
  16. private ?int $menu_id = null;
  17. #[ORM\Column(length: 50, unique: true, nullable: false)]
  18. private ?string $titre = null;
  19. #[ORM\Column(type:"integer", nullable: false)]
  20. private ?int $nombre_personne_minimum = null;
  21. #[ORM\Column(type:"float", nullable: false)]
  22. private ?float $prix_par_personne = null;
  23. #[ORM\Column(length: 50)]
  24. private ?string $regime = null;
  25. #[ORM\Column(length: 50, nullable: false)]
  26. private ?string $description = null;
  27. #[ORM\Column(type:"integer", nullable: false)]
  28. private ?int $quantite_restante = null;
  29. #[ORM\OneToMany(targetEntity: ProposePlat::class, mappedBy: 'menu_id', orphanRemoval: true, cascade: ['persist'])]
  30. private Collection $proposeplat;
  31. #[ORM\OneToOne(targetEntity: ProposeTheme::class, mappedBy: 'menu_id', orphanRemoval: true, cascade: ['persist'])]
  32. private ?ProposeTheme $proposetheme = null;
  33. #[ORM\OneToOne(targetEntity: Adapte::class, mappedBy: 'menu_id', orphanRemoval: true, cascade: ['persist'])]
  34. private ?Adapte $adapte = null;
  35. public function __construct()
  36. {
  37. $this->proposeplat = new ArrayCollection();
  38. }
  39. public function getMenuId(): ?int
  40. {
  41. return $this->menu_id;
  42. }
  43. public function getTitre(): ?string
  44. {
  45. return $this->titre;
  46. }
  47. public function setTitre(string $titre): self
  48. {
  49. $this->titre = $titre;
  50. return $this;
  51. }
  52. public function getNombrePersonneMinimum(): ?int
  53. {
  54. return $this->nombre_personne_minimum;
  55. }
  56. public function setNombrePersonneMinimum(int $nombre_personne_minimum): self
  57. {
  58. $this->nombre_personne_minimum = $nombre_personne_minimum;
  59. return $this;
  60. }
  61. public function getPrixParPersonne(): ?float
  62. {
  63. return $this->prix_par_personne;
  64. }
  65. public function setPrixParPersonne(float $prix_par_personne): self
  66. {
  67. $this->prix_par_personne = $prix_par_personne;
  68. return $this;
  69. }
  70. public function getRegime(): ?string
  71. {
  72. return $this->regime;
  73. }
  74. public function setRegime(string $regime): self
  75. {
  76. $this->regime = $regime;
  77. return $this;
  78. }
  79. public function getDescription(): ?string
  80. {
  81. return $this->description;
  82. }
  83. public function setDescription(string $description): self
  84. {
  85. $this->description = $description;
  86. return $this;
  87. }
  88. public function getQuantiteRestante(): ?int
  89. {
  90. return $this->quantite_restante;
  91. }
  92. public function setQuantiteRestante(int $quantite_restante): self
  93. {
  94. $this->quantite_restante = $quantite_restante;
  95. return $this;
  96. }
  97. /**
  98. * @return Collection<int, ProposePlat>
  99. */
  100. public function getProposeplats(): Collection
  101. {
  102. return $this->proposeplat;
  103. }
  104. public function addProposeplat(ProposePlat $proposeplat): static
  105. {
  106. if (!$this->proposeplat->contains($proposeplat)) {
  107. $this->proposeplat->add($proposeplat);
  108. $proposeplat->setMenuId($this);
  109. }
  110. return $this;
  111. }
  112. public function removeProposeplat(ProposePlat $proposeplat): static
  113. {
  114. if ($this->proposeplat->removeElement($proposeplat)) {
  115. // set the owning side to null (unless already changed)
  116. if ($proposeplat->getMenuId() === $this) {
  117. $proposeplat->setMenuId(null);
  118. }
  119. }
  120. return $this;
  121. }
  122. /**
  123. * @return ProposeTheme<int, ProposeTheme>
  124. */
  125. public function getProposeTheme(): ?ProposeTheme
  126. {
  127. return $this->proposetheme;
  128. }
  129. public function addProposeTheme(ProposeTheme $proposetheme): static
  130. {
  131. if ($this->proposetheme !== $proposetheme) {
  132. $this->proposetheme = $proposetheme;
  133. $proposetheme->setMenuId($this);
  134. }
  135. return $this;
  136. }
  137. public function removeProposeTheme(ProposeTheme $proposetheme): static
  138. {
  139. if ($this->proposetheme === $proposetheme) {
  140. $this->proposetheme = null;
  141. }
  142. return $this;
  143. }
  144. /**
  145. * @return Adapte<int, Adapte>
  146. */
  147. public function getAdapte(): ?Adapte
  148. {
  149. return $this->adapte;
  150. }
  151. public function addAdapte(Adapte $adapte): static
  152. {
  153. if ($this->adapte !== $adapte) {
  154. $this->adapte = $adapte;
  155. $adapte->setMenuId($this);
  156. }
  157. return $this;
  158. }
  159. public function removeAdapte(Adapte $adapte): static
  160. {
  161. if ($this->adapte === $adapte) {
  162. $this->adapte = null;
  163. }
  164. return $this;
  165. }
  166. }