src/Entity/UnidadNegocio.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. use Symfony\Component\Uid\Uuid;
  9. /**
  10. * @ORM\Entity(repositoryClass="App\Repository\UnidadNegocioRepository")
  11. * @ORM\Table(name="unidad_negocio", schema="perseo")
  12. * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
  13. */
  14. class UnidadNegocio
  15. {
  16. /**
  17. * @ORM\Id
  18. * @ORM\Column(type="uuid", unique=true)
  19. * @ORM\GeneratedValue(strategy="CUSTOM")
  20. * @ORM\CustomIdGenerator(class="doctrine.uuid_generator")
  21. */
  22. protected $id;
  23. /**
  24. * @ORM\Column(type="string", nullable=true)
  25. */
  26. protected $nombre;
  27. /**
  28. * @ORM\Column(type="string", nullable=true)
  29. */
  30. protected $descripcion;
  31. /**
  32. * @ORM\Column(type="datetime", nullable=true, name="deleted_at")
  33. */
  34. protected $deletedAt;
  35. /**
  36. * @ORM\Column(type="datetime", nullable=false, name="updated_at", options={"default":"2022-01-01 00:00:00"})
  37. * @Gedmo\Timestampable(on="update")
  38. */
  39. protected $updatedAt;
  40. /**
  41. * @ORM\Column(type="datetime", nullable=false, name="created_at", options={"default":"2022-01-01 00:00:00"})
  42. * @Gedmo\Timestampable(on="create")
  43. */
  44. protected $createdAt;
  45. /**
  46. * @ORM\OneToMany(targetEntity="App\Entity\Valoracion", mappedBy="unidadNegocio")
  47. */
  48. protected $valoraciones;
  49. /**
  50. * @ORM\OneToMany(targetEntity=\App\Entity\ActividadAbstract::class, mappedBy="unidadNegocio")
  51. */
  52. private $actividades;
  53. /**
  54. * @ORM\OneToMany(targetEntity="App\Entity\Usuario", mappedBy="unidadNegocio")
  55. */
  56. protected $usuarios;
  57. /**
  58. * @ORM\OneToMany(targetEntity="App\Entity\Operacion", mappedBy="unidadNegocio")
  59. */
  60. protected $operaciones;
  61. /**
  62. *
  63. * @ORM\JoinColumn(name="responsable_usuario_id", referencedColumnName="id", unique=true)
  64. * @ORM\OneToOne(targetEntity="App\Entity\Usuario", inversedBy="unidadNegocioResponsable")
  65. */
  66. protected $responsable;
  67. /**
  68. * @ORM\ManyToMany(targetEntity="App\Entity\Usuario", inversedBy="unidadesNegocioComercial")
  69. * @ORM\JoinTable(
  70. * name="unidad_negocio_has_comercial",
  71. * joinColumns={@ORM\JoinColumn(name="unidad_negocio_id", referencedColumnName="id", nullable=false)},
  72. * inverseJoinColumns={@ORM\JoinColumn(name="usuario_id", referencedColumnName="id", nullable=false)}
  73. * )
  74. */
  75. protected $comerciales;
  76. public function __construct()
  77. {
  78. $this->valoraciones = new ArrayCollection();
  79. $this->usuarios = new ArrayCollection();
  80. $this->comerciales = new ArrayCollection();
  81. $this->operaciones = new ArrayCollection();
  82. $this->actividades = new ArrayCollection();
  83. }
  84. public function __toString(): string
  85. {
  86. return $this->getNombre()??'---';
  87. }
  88. public function getId(): ?Uuid
  89. {
  90. return $this->id;
  91. }
  92. public function getNombre(): ?string
  93. {
  94. return $this->nombre;
  95. }
  96. public function setNombre(?string $nombre): self
  97. {
  98. $this->nombre = $nombre;
  99. return $this;
  100. }
  101. public function getDescripcion(): ?string
  102. {
  103. return $this->descripcion;
  104. }
  105. public function setDescripcion(?string $descripcion): self
  106. {
  107. $this->descripcion = $descripcion;
  108. return $this;
  109. }
  110. public function getDeletedAt(): ?\DateTimeInterface
  111. {
  112. return $this->deletedAt;
  113. }
  114. public function setDeletedAt(?\DateTimeInterface $deletedAt): self
  115. {
  116. $this->deletedAt = $deletedAt;
  117. return $this;
  118. }
  119. public function getUpdatedAt(): ?\DateTimeInterface
  120. {
  121. return $this->updatedAt;
  122. }
  123. public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  124. {
  125. $this->updatedAt = $updatedAt;
  126. return $this;
  127. }
  128. public function getCreatedAt(): ?\DateTimeInterface
  129. {
  130. return $this->createdAt;
  131. }
  132. public function setCreatedAt(\DateTimeInterface $createdAt): self
  133. {
  134. $this->createdAt = $createdAt;
  135. return $this;
  136. }
  137. /**
  138. * @return Collection|Valoracion[]
  139. */
  140. public function getValoraciones(): Collection
  141. {
  142. return $this->valoraciones;
  143. }
  144. public function addValoracione(Valoracion $valoracione): self
  145. {
  146. if (!$this->valoraciones->contains($valoracione)) {
  147. $this->valoraciones[] = $valoracione;
  148. $valoracione->setUnidadNegocio($this);
  149. }
  150. return $this;
  151. }
  152. public function removeValoracione(Valoracion $valoracione): self
  153. {
  154. if ($this->valoraciones->removeElement($valoracione)) {
  155. // set the owning side to null (unless already changed)
  156. if ($valoracione->getUnidadNegocio() === $this) {
  157. $valoracione->setUnidadNegocio(null);
  158. }
  159. }
  160. return $this;
  161. }
  162. /**
  163. * @return Collection|Usuario[]
  164. */
  165. public function getUsuarios(): Collection
  166. {
  167. return $this->usuarios;
  168. }
  169. public function addUsuario(Usuario $usuario): self
  170. {
  171. if (!$this->usuarios->contains($usuario)) {
  172. $this->usuarios[] = $usuario;
  173. $usuario->setUnidadNegocio($this);
  174. }
  175. return $this;
  176. }
  177. public function removeUsuario(Usuario $usuario): self
  178. {
  179. if ($this->usuarios->removeElement($usuario)) {
  180. // set the owning side to null (unless already changed)
  181. if ($usuario->getUnidadNegocio() === $this) {
  182. $usuario->setUnidadNegocio(null);
  183. }
  184. }
  185. return $this;
  186. }
  187. public function getResponsable(): ?Usuario
  188. {
  189. return $this->responsable;
  190. }
  191. public function setResponsable(?Usuario $responsable): self
  192. {
  193. $this->responsable = $responsable;
  194. return $this;
  195. }
  196. /**
  197. * @return Collection|Usuario[]
  198. */
  199. public function getComerciales(): Collection
  200. {
  201. return $this->comerciales;
  202. }
  203. public function addComerciale(Usuario $comerciale): self
  204. {
  205. if (!$this->comerciales->contains($comerciale)) {
  206. $this->comerciales[] = $comerciale;
  207. }
  208. return $this;
  209. }
  210. public function removeComerciale(Usuario $comerciale): self
  211. {
  212. $this->comerciales->removeElement($comerciale);
  213. return $this;
  214. }
  215. /**
  216. * @return Collection|Operacion[]
  217. */
  218. public function getOperaciones(): Collection
  219. {
  220. return $this->operaciones;
  221. }
  222. public function addOperacione(Operacion $operacione): self
  223. {
  224. if (!$this->operaciones->contains($operacione)) {
  225. $this->operaciones[] = $operacione;
  226. $operacione->setUnidadNegocio($this);
  227. }
  228. return $this;
  229. }
  230. public function removeOperacione(Operacion $operacione): self
  231. {
  232. if ($this->operaciones->removeElement($operacione)) {
  233. // set the owning side to null (unless already changed)
  234. if ($operacione->getUnidadNegocio() === $this) {
  235. $operacione->setUnidadNegocio(null);
  236. }
  237. }
  238. return $this;
  239. }
  240. /**
  241. * @return Collection<int, ActividadAbstract>
  242. */
  243. public function getActividades(): Collection
  244. {
  245. return $this->actividades;
  246. }
  247. public function addActividade(ActividadAbstract $actividade): static
  248. {
  249. if (!$this->actividades->contains($actividade)) {
  250. $this->actividades->add($actividade);
  251. $actividade->setUnidadNegocio($this);
  252. }
  253. return $this;
  254. }
  255. public function removeActividade(ActividadAbstract $actividade): static
  256. {
  257. if ($this->actividades->removeElement($actividade)) {
  258. // set the owning side to null (unless already changed)
  259. if ($actividade->getUnidadNegocio() === $this) {
  260. $actividade->setUnidadNegocio(null);
  261. }
  262. }
  263. return $this;
  264. }
  265. }