src/Entity/Departement.php line 19

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  4. use App\Repository\DepartementRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9. * Departement.
  10. *
  11. * @ORM\Table(name="Departement")
  12. *
  13. * @ORM\Entity(repositoryClass=DepartementRepository::class)
  14. */
  15. class Departement
  16. {
  17. /**
  18. * @var int
  19. *
  20. * @ORM\Column(name="id", type="integer")
  21. *
  22. * @ORM\Id
  23. *
  24. * @ORM\GeneratedValue(strategy="AUTO")
  25. */
  26. private $id;
  27. /**
  28. * @var string
  29. *
  30. * @ORM\Column(name="nom", type="string", length=255)
  31. */
  32. private $nom;
  33. /**
  34. * @var string
  35. *
  36. * @ORM\Column(name="num", type="string", length=255)
  37. */
  38. private $num;
  39. /**
  40. * @ORM\OneToMany(targetEntity="Commune", mappedBy="departement")
  41. */
  42. private $communes;
  43. /**
  44. * @ORM\ManyToOne(targetEntity="Region", inversedBy="departements")
  45. *
  46. * @ORM\JoinColumn(name="region_id", referencedColumnName="id")
  47. */
  48. private $region;
  49. /**
  50. * @ORM\OneToMany(targetEntity="Structure", mappedBy="departement")
  51. */
  52. private $structures;
  53. /**
  54. * @ORM\OneToMany(targetEntity=FiltreStructure::class, mappedBy="departement")
  55. */
  56. private $filtreStructures;
  57. /**
  58. * Constructor.
  59. */
  60. public function __construct()
  61. {
  62. $this->communes = new ArrayCollection();
  63. $this->filtreStructures = new ArrayCollection();
  64. $this->structures = new ArrayCollection();
  65. }
  66. /**
  67. * Methode pour afficher le departement.
  68. */
  69. #[\Override]
  70. public function __toString(): string
  71. {
  72. return $this->getNom();
  73. }
  74. /**
  75. * Get id.
  76. *
  77. * @return int
  78. */
  79. public function getId()
  80. {
  81. return $this->id;
  82. }
  83. /**
  84. * Set nom.
  85. *
  86. * @param string $nom
  87. */
  88. public function setNom($nom): static
  89. {
  90. $this->nom = $nom;
  91. return $this;
  92. }
  93. /**
  94. * Get nom.
  95. *
  96. * @return string
  97. */
  98. public function getNom()
  99. {
  100. return $this->nom;
  101. }
  102. /**
  103. * Add communes.
  104. */
  105. public function addCommune(Commune $communes): static
  106. {
  107. $this->communes[] = $communes;
  108. return $this;
  109. }
  110. /**
  111. * Remove communes.
  112. */
  113. public function removeCommune(Commune $communes): void
  114. {
  115. $this->communes->removeElement($communes);
  116. }
  117. /**
  118. * Get communes.
  119. *
  120. * @return Collection
  121. */
  122. public function getCommunes()
  123. {
  124. return $this->communes;
  125. }
  126. /**
  127. * Set region.
  128. */
  129. public function setRegion(?Region $region = null): static
  130. {
  131. $this->region = $region;
  132. return $this;
  133. }
  134. /**
  135. * Get region.
  136. *
  137. * @return Region
  138. */
  139. public function getRegion()
  140. {
  141. return $this->region;
  142. }
  143. /**
  144. * Set num.
  145. *
  146. * @param string $num
  147. */
  148. public function setNum($num): static
  149. {
  150. $this->num = $num;
  151. return $this;
  152. }
  153. /**
  154. * Get num.
  155. *
  156. * @return string
  157. */
  158. public function getNum()
  159. {
  160. return $this->num;
  161. }
  162. /**
  163. * Add structures.
  164. */
  165. public function addStructure(Structure $structures): static
  166. {
  167. $this->structures[] = $structures;
  168. return $this;
  169. }
  170. /**
  171. * Remove structures.
  172. */
  173. public function removeStructure(Structure $structures): void
  174. {
  175. $this->structures->removeElement($structures);
  176. }
  177. /**
  178. * Get structures.
  179. *
  180. * @return Collection
  181. */
  182. public function getStructures()
  183. {
  184. return $this->structures;
  185. }
  186. /**
  187. * @return Collection<int, FiltreStructure>
  188. */
  189. public function getFiltreStructures(): Collection
  190. {
  191. return $this->filtreStructures;
  192. }
  193. public function addFiltreStructure(FiltreStructure $filtreStructure): self
  194. {
  195. if (!$this->filtreStructures->contains($filtreStructure)) {
  196. $this->filtreStructures[] = $filtreStructure;
  197. $filtreStructure->setDepartement($this);
  198. }
  199. return $this;
  200. }
  201. public function removeFiltreStructure(FiltreStructure $filtreStructure): self
  202. {
  203. // set the owning side to null (unless already changed)
  204. if ($this->filtreStructures->removeElement($filtreStructure) && $filtreStructure->getDepartement() === $this) {
  205. $filtreStructure->setDepartement(null);
  206. }
  207. return $this;
  208. }
  209. }