src/Entity/Emplacement.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use App\Repository\EmplacementRepository;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. #[ORM\Entity(repositoryClass: EmplacementRepository::class)]
  8. class Emplacement
  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)]
  17. private $adr;
  18. #[ORM\Column(type: 'string',length: 5)]
  19. private $cp;
  20. #[ORM\Column(type: 'string',length: 255)]
  21. private $ville;
  22. #[ORM\OneToMany(mappedBy: 'emplacement', targetEntity: Service::class)]
  23. private $services;
  24. #[ORM\Column(type: 'string',length: 255, nullable: true)]
  25. private $url;
  26. #[ORM\OneToMany(mappedBy: 'emplacement', targetEntity: AccesEmplacement::class, cascade:['persist'], orphanRemoval: true)]
  27. private Collection $accesEmplacements;
  28. #[ORM\OneToMany(mappedBy: 'emplacement', targetEntity: Rotation::class, orphanRemoval: true)]
  29. private Collection $rotations;
  30. #[ORM\Column(nullable: true)]
  31. private ?bool $public = null;
  32. #[ORM\ManyToOne(inversedBy: 'emplacements')]
  33. private ?User $createur = null;
  34. public function __construct()
  35. {
  36. $this->services = new ArrayCollection();
  37. $this->accesEmplacements = new ArrayCollection();
  38. $this->rotations = new ArrayCollection();
  39. }
  40. public function __toString(): string
  41. {
  42. return $this->libelle;
  43. }
  44. public function getId(): ?int
  45. {
  46. return $this->id;
  47. }
  48. public function getLibelle(): ?string
  49. {
  50. return $this->libelle;
  51. }
  52. public function setLibelle(string $libelle): self
  53. {
  54. $this->libelle = $libelle;
  55. return $this;
  56. }
  57. public function getAdr(): ?string
  58. {
  59. return $this->adr;
  60. }
  61. public function setAdr(string $adr): self
  62. {
  63. $this->adr = $adr;
  64. return $this;
  65. }
  66. public function getCp(): ?string
  67. {
  68. return $this->cp;
  69. }
  70. public function setCp(string $cp): self
  71. {
  72. $this->cp = $cp;
  73. return $this;
  74. }
  75. public function getVille(): ?string
  76. {
  77. return $this->ville;
  78. }
  79. public function setVille(string $ville): self
  80. {
  81. $this->ville = $ville;
  82. return $this;
  83. }
  84. /**
  85. * @return Collection|Service[]
  86. */
  87. public function getServices(): Collection
  88. {
  89. return $this->services;
  90. }
  91. public function addService(Service $service): self
  92. {
  93. if (!$this->services->contains($service)) {
  94. $this->services[] = $service;
  95. $service->setEmplacement($this);
  96. }
  97. return $this;
  98. }
  99. public function removeService(Service $service): self
  100. {
  101. if ($this->services->removeElement($service)) {
  102. // set the owning side to null (unless already changed)
  103. if ($service->getEmplacement() === $this) {
  104. $service->setEmplacement(null);
  105. }
  106. }
  107. return $this;
  108. }
  109. public function getUrl(): ?string
  110. {
  111. return $this->url;
  112. }
  113. public function setUrl(?string $url): self
  114. {
  115. $this->url = $url;
  116. return $this;
  117. }
  118. /**
  119. * @return Collection<int, AccesEmplacement>
  120. */
  121. public function getAccesEmplacements(): Collection
  122. {
  123. return $this->accesEmplacements;
  124. }
  125. public function addAccesEmplacement(AccesEmplacement $accesEmplacement): self
  126. {
  127. if (!$this->accesEmplacements->contains($accesEmplacement)) {
  128. $this->accesEmplacements->add($accesEmplacement);
  129. $accesEmplacement->setEmplacement($this);
  130. }
  131. return $this;
  132. }
  133. public function removeAccesEmplacement(AccesEmplacement $accesEmplacement): self
  134. {
  135. if ($this->accesEmplacements->removeElement($accesEmplacement)) {
  136. // set the owning side to null (unless already changed)
  137. if ($accesEmplacement->getEmplacement() === $this) {
  138. $accesEmplacement->setEmplacement(null);
  139. }
  140. }
  141. return $this;
  142. }
  143. /**
  144. * @return Collection<int, Rotation>
  145. */
  146. public function getRotations(): Collection
  147. {
  148. return $this->rotations;
  149. }
  150. public function addRotation(Rotation $rotation): self
  151. {
  152. if (!$this->rotations->contains($rotation)) {
  153. $this->rotations->add($rotation);
  154. $rotation->setEmplacement($this);
  155. }
  156. return $this;
  157. }
  158. public function removeRotation(Rotation $rotation): self
  159. {
  160. if ($this->rotations->removeElement($rotation)) {
  161. // set the owning side to null (unless already changed)
  162. if ($rotation->getEmplacement() === $this) {
  163. $rotation->setEmplacement(null);
  164. }
  165. }
  166. return $this;
  167. }
  168. public function isPublic(): ?bool
  169. {
  170. return $this->public;
  171. }
  172. public function setPublic(?bool $public): static
  173. {
  174. $this->public = $public;
  175. return $this;
  176. }
  177. public function getCreateur(): ?User
  178. {
  179. return $this->createur;
  180. }
  181. public function setCreateur(?User $createur): static
  182. {
  183. $this->createur = $createur;
  184. return $this;
  185. }
  186. }