src/Entity/Region.php line 18

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