src/Entity/Service.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ServiceRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. #[ORM\Entity(repositoryClass: ServiceRepository::class)]
  9. class Service
  10. {
  11. #[ORM\Id]
  12. #[ORM\GeneratedValue]
  13. #[ORM\Column(type: 'integer')]
  14. private $id;
  15. #[Assert\NotBlank()]
  16. #[ORM\Column(type: 'date')]
  17. private $date;
  18. #[Assert\NotBlank()]
  19. #[ORM\Column(type: 'datetime_immutable')]
  20. private $debutService;
  21. #[Assert\NotBlank()]
  22. #[ORM\Column(type: 'datetime_immutable')]
  23. private $finService;
  24. #[ORM\OneToMany(mappedBy: 'service', targetEntity: Menu::class, orphanRemoval: true)]
  25. private $menus;
  26. #[Assert\NotBlank()]
  27. #[ORM\ManyToOne(targetEntity: Emplacement::class, inversedBy:'services')]
  28. #[ORM\JoinColumn(nullable:false)]
  29. private $emplacement = null;
  30. #[ORM\OneToMany(mappedBy: 'service', targetEntity: Commande::class, orphanRemoval: true)]
  31. private $commandes;
  32. #[ORM\OneToMany(mappedBy: 'service', targetEntity: Retrait::class, orphanRemoval: true)]
  33. private $retraits;
  34. #[Assert\NotBlank()]
  35. #[ORM\ManyToOne(targetEntity:Foodtruck::class, inversedBy: 'services')]
  36. #[ORM\JoinColumn(nullable: false)]
  37. private $foodtruck;
  38. #[ORM\Column(nullable: true)]
  39. private ?bool $ouvert = false;
  40. #[ORM\Column(nullable: true)]
  41. private ?bool $commandable = true;
  42. #[ORM\Column(nullable: true)]
  43. private ?bool $quantiteVisible = true;
  44. #[ORM\Column(nullable: true)]
  45. private ?bool $prixVisible = true;
  46. public function __toString()
  47. {
  48. return 'Service n° '.$this->id.' du '.$this->date->format('d/m/Y');
  49. }
  50. public function __construct()
  51. {
  52. $this->menus = new ArrayCollection();
  53. $this->commandes = new ArrayCollection();
  54. $this->retraits = new ArrayCollection();
  55. }
  56. public function getId(): ?int
  57. {
  58. return $this->id;
  59. }
  60. public function getDate(): ?\DateTimeInterface
  61. {
  62. return $this->date;
  63. }
  64. public function setDate(\DateTimeInterface $date): self
  65. {
  66. $this->date = $date;
  67. return $this;
  68. }
  69. public function getDebutService(): ?\DateTimeInterface
  70. {
  71. return $this->debutService;
  72. }
  73. public function setDebutService(\DateTimeInterface $debutService): self
  74. {
  75. $this->debutService = $debutService;
  76. return $this;
  77. }
  78. public function getFinService(): ?\DateTimeInterface
  79. {
  80. return $this->finService;
  81. }
  82. public function setFinService(\DateTimeInterface $finService): self
  83. {
  84. $this->finService = $finService;
  85. return $this;
  86. }
  87. /**
  88. * @return Collection<int, Menu>
  89. */
  90. public function getMenus(): Collection
  91. {
  92. return $this->menus;
  93. }
  94. public function addMenu(Menu $menu): self
  95. {
  96. if (!$this->menus->contains($menu)) {
  97. $this->menus->add($menu);
  98. $menu->setService($this);
  99. }
  100. return $this;
  101. }
  102. public function removeMenu(Menu $menu): self
  103. {
  104. if ($this->menus->removeElement($menu)) {
  105. // set the owning side to null (unless already changed)
  106. if ($menu->getService() === $this) {
  107. $menu->setService(null);
  108. }
  109. }
  110. return $this;
  111. }
  112. public function getEmplacement(): ?Emplacement
  113. {
  114. return $this->emplacement;
  115. }
  116. public function setEmplacement(?Emplacement $emplacement): self
  117. {
  118. $this->emplacement = $emplacement;
  119. return $this;
  120. }
  121. /**
  122. * @return Collection<int, Commande>
  123. */
  124. public function getCommandes(): Collection
  125. {
  126. return $this->commandes;
  127. }
  128. public function addCommande(Commande $commande): self
  129. {
  130. if (!$this->commandes->contains($commande)) {
  131. $this->commandes->add($commande);
  132. $commande->setService($this);
  133. }
  134. return $this;
  135. }
  136. public function removeCommande(Commande $commande): self
  137. {
  138. if ($this->commandes->removeElement($commande)) {
  139. // set the owning side to null (unless already changed)
  140. if ($commande->getService() === $this) {
  141. $commande->setService(null);
  142. }
  143. }
  144. return $this;
  145. }
  146. /**
  147. * @return Collection<int, Retrait>
  148. */
  149. public function getRetraits(): Collection
  150. {
  151. return $this->retraits;
  152. }
  153. public function addRetrait(Retrait $retrait): self
  154. {
  155. if (!$this->retraits->contains($retrait)) {
  156. $this->retraits->add($retrait);
  157. $retrait->setService($this);
  158. }
  159. return $this;
  160. }
  161. public function removeRetrait(Retrait $retrait): self
  162. {
  163. if ($this->retraits->removeElement($retrait)) {
  164. // set the owning side to null (unless already changed)
  165. if ($retrait->getService() === $this) {
  166. $retrait->setService(null);
  167. }
  168. }
  169. return $this;
  170. }
  171. public function getFoodtruck(): ?Foodtruck
  172. {
  173. return $this->foodtruck;
  174. }
  175. public function setFoodtruck(?Foodtruck $foodtruck): self
  176. {
  177. $this->foodtruck = $foodtruck;
  178. return $this;
  179. }
  180. public function isOuvert(): ?bool
  181. {
  182. return $this->ouvert;
  183. }
  184. public function setOuvert(?bool $ouvert): self
  185. {
  186. $this->ouvert = $ouvert;
  187. return $this;
  188. }
  189. public function isCommandable(): ?bool
  190. {
  191. return $this->commandable;
  192. }
  193. public function setCommandable(?bool $commandable): static
  194. {
  195. $this->commandable = $commandable;
  196. return $this;
  197. }
  198. public function isQuantiteVisible(): ?bool
  199. {
  200. return $this->quantiteVisible;
  201. }
  202. public function setQuantiteVisible(?bool $quantiteVisible): static
  203. {
  204. $this->quantiteVisible = $quantiteVisible;
  205. return $this;
  206. }
  207. public function isPrixVisible(): ?bool
  208. {
  209. return $this->prixVisible;
  210. }
  211. public function setPrixVisible(?bool $prixVisible): static
  212. {
  213. $this->prixVisible = $prixVisible;
  214. return $this;
  215. }
  216. }