src/Entity/Preparation.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PreparationRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClass: PreparationRepository::class)]
  8. class Preparation
  9. {
  10. #[ORM\Id]
  11. #[ORM\GeneratedValue]
  12. #[ORM\Column(type: 'integer')]
  13. private $id;
  14. #[ORM\Column(type: 'string',length: 255)]
  15. private $libelle;
  16. #[ORM\Column(type: 'string',length: 255, nullable: true)]
  17. private $description;
  18. #[ORM\Column(type: 'string',length: 255, nullable: true)]
  19. private $img;
  20. #[ORM\OneToMany(mappedBy: 'preparation', targetEntity: Ingredient::class, orphanRemoval: true)]
  21. private $ingredients;
  22. #[ORM\ManyToOne(targetEntity: Categorie::class, inversedBy:'preparations')]
  23. private $categorie;
  24. #[ORM\OneToMany(mappedBy: 'preparation', targetEntity: LigneCommande::class, orphanRemoval: true)]
  25. private $lignesCommande;
  26. #[ORM\OneToMany(mappedBy: 'preparation', targetEntity: Menu::class, orphanRemoval: true)]
  27. private $menus;
  28. #[ORM\ManyToOne(targetEntity:Foodtruck::class, inversedBy: 'preparations')]
  29. private $foodtruck;
  30. public function __toString()
  31. {
  32. return $this->libelle;
  33. }
  34. public function __construct()
  35. {
  36. $this->ingredients = new ArrayCollection();
  37. $this->lignesCommande = new ArrayCollection();
  38. $this->menus = new ArrayCollection();
  39. }
  40. public function getId(): ?int
  41. {
  42. return $this->id;
  43. }
  44. public function getLibelle(): ?string
  45. {
  46. return $this->libelle;
  47. }
  48. public function setLibelle(string $libelle): self
  49. {
  50. $this->libelle = $libelle;
  51. return $this;
  52. }
  53. public function getDescription(): ?string
  54. {
  55. return $this->description;
  56. }
  57. public function setDescription(?string $description): self
  58. {
  59. $this->description = $description;
  60. return $this;
  61. }
  62. public function getImg(): ?string
  63. {
  64. return $this->img;
  65. }
  66. public function setImg(?string $img): self
  67. {
  68. $this->img = $img;
  69. return $this;
  70. }
  71. /**
  72. * @return Collection|Ingredient[]
  73. */
  74. public function getIngredients(): Collection
  75. {
  76. return $this->ingredients;
  77. }
  78. public function addIngredient(Ingredient $ingredient): self
  79. {
  80. if (!$this->ingredients->contains($ingredient)) {
  81. $this->ingredients[] = $ingredient;
  82. $ingredient->setPreparation($this);
  83. }
  84. return $this;
  85. }
  86. public function removeIngredient(Ingredient $ingredient): self
  87. {
  88. if ($this->ingredients->removeElement($ingredient)) {
  89. // set the owning side to null (unless already changed)
  90. if ($ingredient->getPreparation() === $this) {
  91. $ingredient->setPreparation(null);
  92. }
  93. }
  94. return $this;
  95. }
  96. public function getCategorie(): ?Categorie
  97. {
  98. return $this->categorie;
  99. }
  100. public function setCategorie(?Categorie $categorie): self
  101. {
  102. $this->categorie = $categorie;
  103. return $this;
  104. }
  105. /**
  106. * @return Collection|LigneCommande[]
  107. */
  108. public function getLignesCommande(): Collection
  109. {
  110. return $this->lignesCommande;
  111. }
  112. public function addLignesCommande(LigneCommande $lignesCommande): self
  113. {
  114. if (!$this->lignesCommande->contains($lignesCommande)) {
  115. $this->lignesCommande[] = $lignesCommande;
  116. $lignesCommande->setPreparation($this);
  117. }
  118. return $this;
  119. }
  120. public function removeLignesCommande(LigneCommande $lignesCommande): self
  121. {
  122. if ($this->lignesCommande->removeElement($lignesCommande)) {
  123. // set the owning side to null (unless already changed)
  124. if ($lignesCommande->getPreparation() === $this) {
  125. $lignesCommande->setPreparation(null);
  126. }
  127. }
  128. return $this;
  129. }
  130. /**
  131. * @return Collection<int, Menu>
  132. */
  133. public function getMenus(): Collection
  134. {
  135. return $this->menus;
  136. }
  137. public function addMenu(Menu $menu): self
  138. {
  139. if (!$this->menus->contains($menu)) {
  140. $this->menus->add($menu);
  141. $menu->setPreparation($this);
  142. }
  143. return $this;
  144. }
  145. public function removeMenu(Menu $menu): self
  146. {
  147. if ($this->menus->removeElement($menu)) {
  148. // set the owning side to null (unless already changed)
  149. if ($menu->getPreparation() === $this) {
  150. $menu->setPreparation(null);
  151. }
  152. }
  153. return $this;
  154. }
  155. public function getFoodtruck(): ?Foodtruck
  156. {
  157. return $this->foodtruck;
  158. }
  159. public function setFoodtruck(?Foodtruck $foodtruck): self
  160. {
  161. $this->foodtruck = $foodtruck;
  162. return $this;
  163. }
  164. }