src/Entity/Localidad.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\LocalidadRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use JMS\Serializer\Annotation as Serializer;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. #[UniqueEntity('slug')]
  11. #[ORM\Entity(repositoryClass: LocalidadRepository::class)]
  12. class Localidad {
  13. #[ORM\Id]
  14. #[ORM\GeneratedValue]
  15. #[ORM\Column(type: 'integer')]
  16. #[Serializer\Groups(groups: ['api'])]
  17. private $id;
  18. #[Assert\NotBlank]
  19. #[ORM\Column(type: 'string')]
  20. private ?string $nombre = null;
  21. #[ORM\Column(type: 'boolean')]
  22. private bool $visible = true;
  23. #[ORM\Column(type: 'boolean')]
  24. private bool $borrado = false;
  25. #[Assert\NotBlank]
  26. #[ORM\ManyToOne(targetEntity: Comarca::class, inversedBy: 'localidades')]
  27. #[ORM\JoinColumn(nullable: false)]
  28. #[Serializer\Groups(groups: ['api'])]
  29. private ?Comarca $comarca = null;
  30. #[ORM\Column(type: 'boolean')]
  31. private bool $tieneMenos5000Habitantes = false;
  32. #[ORM\OneToMany(targetEntity: Curso::class, mappedBy: 'localidad')]
  33. private Collection $cursos;
  34. #[Assert\NotBlank]
  35. #[Assert\Regex(pattern: '/^[a-z0-9]+(?:-[a-z0-9]+)*$/')]
  36. #[ORM\Column(type: 'string', length: 190, nullable: true, unique: true)]
  37. private ?string $slug = null;
  38. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  39. private ?string $seoTitle = null;
  40. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  41. private ?string $seoDescription = null;
  42. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  43. private ?string $seoKeywords = null;
  44. #[ORM\OneToMany(targetEntity: Usuario::class, mappedBy: 'localidad')]
  45. private Collection $usuarios;
  46. #[ORM\OneToMany(targetEntity: Solicitud::class, mappedBy: 'localidad')]
  47. private Collection $solicitudes;
  48. #[ORM\OneToMany(mappedBy: 'localidad', targetEntity: JornadaCurso::class)]
  49. private Collection $jornadasCursos;
  50. public function __construct()
  51. {
  52. $this->cursos = new ArrayCollection();
  53. $this->usuarios = new ArrayCollection();
  54. $this->solicitudes = new ArrayCollection();
  55. $this->jornadasCursos = new ArrayCollection();
  56. }
  57. public function getId(): ?int
  58. {
  59. return $this->id;
  60. }
  61. public function getNombre(): ?string
  62. {
  63. return $this->nombre;
  64. }
  65. /**
  66. * @param mixed $nombre
  67. */
  68. public function setNombre(?string $nombre): self
  69. {
  70. $this->nombre = $nombre;
  71. return $this;
  72. }
  73. public function isVisible(): ?bool
  74. {
  75. return $this->visible;
  76. }
  77. public function setVisible(bool $visible): self
  78. {
  79. $this->visible = $visible;
  80. return $this;
  81. }
  82. public function isBorrado(): ?bool
  83. {
  84. return $this->borrado;
  85. }
  86. public function setBorrado(bool $borrado): self
  87. {
  88. $this->borrado = $borrado;
  89. return $this;
  90. }
  91. public function getComarca(): ?Comarca
  92. {
  93. return $this->comarca;
  94. }
  95. public function setComarca(?Comarca $comarca): self
  96. {
  97. $this->comarca = $comarca;
  98. return $this;
  99. }
  100. public function isTieneMenos5000Habitantes(): ?bool
  101. {
  102. return $this->tieneMenos5000Habitantes;
  103. }
  104. public function setTieneMenos5000Habitantes(bool $tieneMenos5000Habitantes): self
  105. {
  106. $this->tieneMenos5000Habitantes = $tieneMenos5000Habitantes;
  107. return $this;
  108. }
  109. /**
  110. * @return Collection<int, Curso>
  111. */
  112. public function getCursos(): Collection
  113. {
  114. return $this->cursos;
  115. }
  116. public function addCurso(Curso $curso): self
  117. {
  118. if (!$this->cursos->contains($curso)) {
  119. $this->cursos[] = $curso;
  120. $curso->setLocalidad($this);
  121. }
  122. return $this;
  123. }
  124. public function removeCurso(Curso $curso): self
  125. {
  126. // set the owning side to null (unless already changed)
  127. if ($this->cursos->removeElement($curso) && $curso->getLocalidad() === $this) {
  128. $curso->setLocalidad(null);
  129. }
  130. return $this;
  131. }
  132. public function getSlug(): ?string
  133. {
  134. return $this->slug;
  135. }
  136. public function setSlug(?string $slug): self
  137. {
  138. $this->slug = $slug;
  139. return $this;
  140. }
  141. public function getSeoTitle(): ?string
  142. {
  143. return $this->seoTitle;
  144. }
  145. public function setSeoTitle(?string $seoTitle): self
  146. {
  147. $this->seoTitle = $seoTitle;
  148. return $this;
  149. }
  150. public function getSeoDescription(): ?string
  151. {
  152. return $this->seoDescription;
  153. }
  154. public function setSeoDescription(?string $seoDescription): self
  155. {
  156. $this->seoDescription = $seoDescription;
  157. return $this;
  158. }
  159. public function getSeoKeywords(): ?string
  160. {
  161. return $this->seoKeywords;
  162. }
  163. public function setSeoKeywords(?string $seoKeywords): self
  164. {
  165. $this->seoKeywords = $seoKeywords;
  166. return $this;
  167. }
  168. /**
  169. * @return Collection<int, Usuario>
  170. */
  171. public function getUsuarios(): Collection
  172. {
  173. return $this->usuarios;
  174. }
  175. public function addUsuario(Usuario $usuario): self
  176. {
  177. if (!$this->usuarios->contains($usuario)) {
  178. $this->usuarios[] = $usuario;
  179. $usuario->setLocalidad($this);
  180. }
  181. return $this;
  182. }
  183. public function removeUsuario(Usuario $usuario): self
  184. {
  185. // set the owning side to null (unless already changed)
  186. if ($this->usuarios->removeElement($usuario) && $usuario->getLocalidad() === $this) {
  187. $usuario->setLocalidad(null);
  188. }
  189. return $this;
  190. }
  191. /**
  192. * @return Collection<int, Solicitud>
  193. */
  194. public function getSolicitudes(): Collection
  195. {
  196. return $this->solicitudes;
  197. }
  198. public function addSolicitude(Solicitud $solicitude): self
  199. {
  200. if (!$this->solicitudes->contains($solicitude)) {
  201. $this->solicitudes[] = $solicitude;
  202. $solicitude->setLocalidad($this);
  203. }
  204. return $this;
  205. }
  206. public function removeSolicitude(Solicitud $solicitude): self
  207. {
  208. // set the owning side to null (unless already changed)
  209. if ($this->solicitudes->removeElement($solicitude) && $solicitude->getLocalidad() === $this) {
  210. $solicitude->setLocalidad(null);
  211. }
  212. return $this;
  213. }
  214. /**
  215. * @return Collection<int, JornadaCurso>
  216. */
  217. public function getJornadasCursos(): Collection
  218. {
  219. return $this->jornadasCursos;
  220. }
  221. public function addJornadasCurso(JornadaCurso $jornadasCurso): static
  222. {
  223. if (!$this->jornadasCursos->contains($jornadasCurso)) {
  224. $this->jornadasCursos->add($jornadasCurso);
  225. $jornadasCurso->setLocalidad($this);
  226. }
  227. return $this;
  228. }
  229. public function removeJornadasCurso(JornadaCurso $jornadasCurso): static
  230. {
  231. if ($this->jornadasCursos->removeElement($jornadasCurso)) {
  232. // set the owning side to null (unless already changed)
  233. if ($jornadasCurso->getLocalidad() === $this) {
  234. $jornadasCurso->setLocalidad(null);
  235. }
  236. }
  237. return $this;
  238. }
  239. }