src/Entity/EmpresaFormacion.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\EmpresaFormacionRepository;
  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: EmpresaFormacionRepository::class)]
  9. class EmpresaFormacion
  10. {
  11. #[ORM\Id]
  12. #[ORM\GeneratedValue]
  13. #[ORM\Column(type: 'integer')]
  14. private $id;
  15. #[Assert\NotBlank]
  16. #[ORM\Column(type: 'string', length: 255)]
  17. private ?string $nombre = null;
  18. #[ORM\Column(type: 'boolean')]
  19. private bool $visible = true;
  20. #[ORM\Column(type: 'boolean')]
  21. private bool $borrado = false;
  22. #[ORM\OneToMany(targetEntity: Curso::class, mappedBy: 'empresaFormacion')]
  23. private Collection $cursos;
  24. #[ORM\Column(length: 9)]
  25. #[Assert\NotBlank]
  26. #[Assert\Regex(pattern: '#(^[ABCDEFGHJKLMNPQRSUVWabcdefghjklmnpqrsuvw]\d{7}[0-9A-J])$|(^\d{8}[TRWAGMYFPDXBNJZSQVHLCKEtrwagmyfpdxbnjzsqvhlcke]$)#')]
  27. private ?string $cif = null;
  28. #[ORM\Column(length: 255, nullable: true)]
  29. private ?string $email = null;
  30. #[ORM\Column(length: 255, nullable: true)]
  31. private ?string $personaContacto = null;
  32. #[ORM\Column(length: 9, nullable: true)]
  33. #[Assert\Regex(pattern: '/^\d{9}$/i')]
  34. private ?string $telefonoPersonaContacto = null;
  35. #[ORM\OneToMany(mappedBy: 'empresaFormacion', targetEntity: Usuario::class)]
  36. private Collection $usuarios;
  37. public function __construct()
  38. {
  39. $this->cursos = new ArrayCollection();
  40. $this->usuarios = new ArrayCollection();
  41. }
  42. public function getId(): ?int
  43. {
  44. return $this->id;
  45. }
  46. public function getNombre(): ?string
  47. {
  48. return $this->nombre;
  49. }
  50. public function setNombre(string $nombre): self
  51. {
  52. $this->nombre = $nombre;
  53. return $this;
  54. }
  55. public function isVisible(): ?bool
  56. {
  57. return $this->visible;
  58. }
  59. public function setVisible(bool $visible): self
  60. {
  61. $this->visible = $visible;
  62. return $this;
  63. }
  64. public function isBorrado(): ?bool
  65. {
  66. return $this->borrado;
  67. }
  68. public function setBorrado(bool $borrado): self
  69. {
  70. $this->borrado = $borrado;
  71. return $this;
  72. }
  73. /**
  74. * @return Collection<int, Curso>
  75. */
  76. public function getCursos(): Collection
  77. {
  78. return $this->cursos;
  79. }
  80. public function addCurso(Curso $curso): self
  81. {
  82. if (!$this->cursos->contains($curso)) {
  83. $this->cursos[] = $curso;
  84. $curso->setEmpresaFormacion($this);
  85. }
  86. return $this;
  87. }
  88. public function removeCurso(Curso $curso): self
  89. {
  90. // set the owning side to null (unless already changed)
  91. if ($this->cursos->removeElement($curso) && $curso->getEmpresaFormacion() === $this) {
  92. $curso->setEmpresaFormacion(null);
  93. }
  94. return $this;
  95. }
  96. public function getCif(): ?string
  97. {
  98. return $this->cif;
  99. }
  100. public function setCif(string $cif): static
  101. {
  102. $this->cif = mb_strtoupper($cif);
  103. return $this;
  104. }
  105. public function getEmail(): ?string
  106. {
  107. return $this->email;
  108. }
  109. public function setEmail(?string $email): static
  110. {
  111. $this->email = $email;
  112. return $this;
  113. }
  114. public function getPersonaContacto(): ?string
  115. {
  116. return $this->personaContacto;
  117. }
  118. public function setPersonaContacto(?string $personaContacto): static
  119. {
  120. $this->personaContacto = $personaContacto;
  121. return $this;
  122. }
  123. public function getTelefonoPersonaContacto(): ?string
  124. {
  125. return $this->telefonoPersonaContacto;
  126. }
  127. public function setTelefonoPersonaContacto(string $telefonoPersonaContacto): static
  128. {
  129. $this->telefonoPersonaContacto = $telefonoPersonaContacto;
  130. return $this;
  131. }
  132. /**
  133. * @return Collection<int, Usuario>
  134. */
  135. public function getUsuarios(): Collection
  136. {
  137. return $this->usuarios;
  138. }
  139. public function addUsuario(Usuario $usuario): static
  140. {
  141. if (!$this->usuarios->contains($usuario)) {
  142. $this->usuarios->add($usuario);
  143. $usuario->setEmpresaFormacion($this);
  144. }
  145. return $this;
  146. }
  147. public function removeUsuario(Usuario $usuario): static
  148. {
  149. if ($this->usuarios->removeElement($usuario)) {
  150. // set the owning side to null (unless already changed)
  151. if ($usuario->getEmpresaFormacion() === $this) {
  152. $usuario->setEmpresaFormacion(null);
  153. }
  154. }
  155. return $this;
  156. }
  157. }