src/Entity/Usuario.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\Table(name="usuario", schema="perseo")
  11. * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
  12. * @ORM\Entity(repositoryClass="App\Repository\UsuarioRepository")
  13. */
  14. class Usuario
  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", unique=true, length=5, nullable=false, name="id_perseo")
  25. */
  26. protected $IDperseo;
  27. /**
  28. * @ORM\Column(type="string", nullable=true)
  29. */
  30. protected $avatar;
  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\OneToOne(targetEntity="App\Entity\User", mappedBy="usuario", cascade={"persist"})
  47. */
  48. protected $user;
  49. /**
  50. * @ORM\OneToOne(targetEntity="App\Entity\UnidadNegocio", mappedBy="responsable")
  51. */
  52. protected $unidadNegocioResponsable;
  53. /**
  54. * @ORM\OneToMany(targetEntity="App\Entity\Valoracion", mappedBy="usuario")
  55. */
  56. protected $valoraciones;
  57. /**
  58. * @ORM\OneToMany(targetEntity=\App\Entity\ActividadAbstract::class, mappedBy="usuario")
  59. */
  60. private $actividades;
  61. /**
  62. * @ORM\OneToMany(targetEntity="App\Entity\Operacion", mappedBy="usuario")
  63. */
  64. protected $operaciones;
  65. /**
  66. * @ORM\ManyToOne(targetEntity="App\Entity\UnidadNegocio", inversedBy="usuarios")
  67. * @ORM\JoinColumn(name="unidad_negocio_id", referencedColumnName="id")
  68. */
  69. protected $unidadNegocio;
  70. /**
  71. * @ORM\ManyToMany(targetEntity="App\Entity\UnidadNegocio", mappedBy="comerciales")
  72. */
  73. protected $unidadesNegocioComercial;
  74. public function __construct()
  75. {
  76. $this->user = new User();
  77. $this->valoraciones = new ArrayCollection();
  78. $this->unidadesNegocioComercial = new ArrayCollection();
  79. $this->operaciones = new ArrayCollection();
  80. $this->actividades = new ArrayCollection();
  81. }
  82. public function __toString(): string
  83. {
  84. return $this->getUser()?->getNombreCompleto()??$this->getUser()?->getUserIdentifier();
  85. }
  86. public function getId(): ?Uuid
  87. {
  88. return $this->id;
  89. }
  90. public function getIDperseo(): ?string
  91. {
  92. return $this->IDperseo;
  93. }
  94. public function setIDperseo(string $IDperseo): self
  95. {
  96. $this->IDperseo = $IDperseo;
  97. return $this;
  98. }
  99. public function getAvatar(): ?string
  100. {
  101. return $this->avatar;
  102. }
  103. public function setAvatar(?string $avatar): self
  104. {
  105. $this->avatar = $avatar;
  106. return $this;
  107. }
  108. public function getDeletedAt(): ?\DateTimeInterface
  109. {
  110. return $this->deletedAt;
  111. }
  112. public function setDeletedAt(?\DateTimeInterface $deletedAt): self
  113. {
  114. $this->deletedAt = $deletedAt;
  115. return $this;
  116. }
  117. public function getUpdatedAt(): ?\DateTimeInterface
  118. {
  119. return $this->updatedAt;
  120. }
  121. public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  122. {
  123. $this->updatedAt = $updatedAt;
  124. return $this;
  125. }
  126. public function getCreatedAt(): ?\DateTimeInterface
  127. {
  128. return $this->createdAt;
  129. }
  130. public function setCreatedAt(\DateTimeInterface $createdAt): self
  131. {
  132. $this->createdAt = $createdAt;
  133. return $this;
  134. }
  135. public function getUser(): ?User
  136. {
  137. return $this->user;
  138. }
  139. public function setUser(?User $user): self
  140. {
  141. // unset the owning side of the relation if necessary
  142. if ($user === null && $this->user !== null) {
  143. $this->user->setUsuario(null);
  144. }
  145. // set the owning side of the relation if necessary
  146. if ($user !== null && $user->getUsuario() !== $this) {
  147. $user->setUsuario($this);
  148. }
  149. $this->user = $user;
  150. return $this;
  151. }
  152. public function getUnidadNegocioResponsable(): ?UnidadNegocio
  153. {
  154. return $this->unidadNegocioResponsable;
  155. }
  156. public function setUnidadNegocioResponsable(?UnidadNegocio $unidadNegocioResponsable): self
  157. {
  158. // unset the owning side of the relation if necessary
  159. if ($unidadNegocioResponsable === null && $this->unidadNegocioResponsable !== null) {
  160. $this->unidadNegocioResponsable->setResponsable(null);
  161. }
  162. // set the owning side of the relation if necessary
  163. if ($unidadNegocioResponsable !== null && $unidadNegocioResponsable->getResponsable() !== $this) {
  164. $unidadNegocioResponsable->setResponsable($this);
  165. }
  166. $this->unidadNegocioResponsable = $unidadNegocioResponsable;
  167. return $this;
  168. }
  169. /**
  170. * @return Collection|Valoracion[]
  171. */
  172. public function getValoraciones(): Collection
  173. {
  174. return $this->valoraciones;
  175. }
  176. public function addValoracione(Valoracion $valoracione): self
  177. {
  178. if (!$this->valoraciones->contains($valoracione)) {
  179. $this->valoraciones[] = $valoracione;
  180. $valoracione->setUsuario($this);
  181. }
  182. return $this;
  183. }
  184. public function removeValoracione(Valoracion $valoracione): self
  185. {
  186. if ($this->valoraciones->removeElement($valoracione)) {
  187. // set the owning side to null (unless already changed)
  188. if ($valoracione->getUsuario() === $this) {
  189. $valoracione->setUsuario(null);
  190. }
  191. }
  192. return $this;
  193. }
  194. public function getUnidadNegocio(): ?UnidadNegocio
  195. {
  196. return $this->unidadNegocio;
  197. }
  198. public function setUnidadNegocio(?UnidadNegocio $unidadNegocio): self
  199. {
  200. $this->unidadNegocio = $unidadNegocio;
  201. return $this;
  202. }
  203. /**
  204. * @return Collection|UnidadNegocio[]
  205. */
  206. public function getUnidadesNegocioComercial(): Collection
  207. {
  208. return $this->unidadesNegocioComercial;
  209. }
  210. public function addUnidadesNegocioComercial(UnidadNegocio $unidadesNegocioComercial): self
  211. {
  212. if (!$this->unidadesNegocioComercial->contains($unidadesNegocioComercial)) {
  213. $this->unidadesNegocioComercial[] = $unidadesNegocioComercial;
  214. $unidadesNegocioComercial->addComerciale($this);
  215. }
  216. return $this;
  217. }
  218. public function removeUnidadesNegocioComercial(UnidadNegocio $unidadesNegocioComercial): self
  219. {
  220. if ($this->unidadesNegocioComercial->removeElement($unidadesNegocioComercial)) {
  221. $unidadesNegocioComercial->removeComerciale($this);
  222. }
  223. return $this;
  224. }
  225. /**
  226. * @return Collection|Operacion[]
  227. */
  228. public function getOperaciones(): Collection
  229. {
  230. return $this->operaciones;
  231. }
  232. public function addOperacione(Operacion $operacione): self
  233. {
  234. if (!$this->operaciones->contains($operacione)) {
  235. $this->operaciones[] = $operacione;
  236. $operacione->setUsuario($this);
  237. }
  238. return $this;
  239. }
  240. public function removeOperacione(Operacion $operacione): self
  241. {
  242. if ($this->operaciones->removeElement($operacione)) {
  243. // set the owning side to null (unless already changed)
  244. if ($operacione->getUsuario() === $this) {
  245. $operacione->setUsuario(null);
  246. }
  247. }
  248. return $this;
  249. }
  250. /**
  251. * @return Collection<int, ActividadAbstract>
  252. */
  253. public function getActividades(): Collection
  254. {
  255. return $this->actividades;
  256. }
  257. public function addActividade(ActividadAbstract $actividade): static
  258. {
  259. if (!$this->actividades->contains($actividade)) {
  260. $this->actividades->add($actividade);
  261. $actividade->setUsuario($this);
  262. }
  263. return $this;
  264. }
  265. public function removeActividade(ActividadAbstract $actividade): static
  266. {
  267. if ($this->actividades->removeElement($actividade)) {
  268. // set the owning side to null (unless already changed)
  269. if ($actividade->getUsuario() === $this) {
  270. $actividade->setUsuario(null);
  271. }
  272. }
  273. return $this;
  274. }
  275. }