src/Entity/Usuario.php line 16

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