<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @ORM\Table(name="usuario", schema="perseo")
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
* @ORM\Entity(repositoryClass="App\Repository\UsuarioRepository")
*/
class Usuario
{
/**
* @ORM\Id
* @ORM\Column(type="bigint", options={"unsigned":true})
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", unique=true, length=5, nullable=false, name="id_perseo")
*/
protected $IDperseo;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $avatar;
/**
* @ORM\Column(type="datetime", nullable=true, name="deleted_at")
*/
protected $deletedAt;
/**
* @ORM\Column(type="datetime", nullable=false, name="updated_at", options={"default":"2022-01-01 00:00:00"})
* @Gedmo\Timestampable(on="update")
*/
protected $updatedAt;
/**
* @ORM\Column(type="datetime", nullable=false, name="created_at", options={"default":"2022-01-01 00:00:00"})
* @Gedmo\Timestampable(on="create")
*/
protected $createdAt;
/**
* @ORM\OneToOne(targetEntity="App\Entity\User", mappedBy="usuario", cascade={"persist"})
*/
protected $user;
/**
* @ORM\OneToOne(targetEntity="App\Entity\UnidadNegocio", mappedBy="responsable")
*/
protected $unidadNegocioResponsable;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Valoracion", mappedBy="usuario")
*/
protected $valoraciones;
/**
* @ORM\OneToMany(targetEntity=\App\Entity\ActividadAbstract::class, mappedBy="usuario")
*/
private $actividades;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Operacion", mappedBy="usuario")
*/
protected $operaciones;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\UnidadNegocio", inversedBy="usuarios")
* @ORM\JoinColumn(name="unidad_negocio_id", referencedColumnName="id")
*/
protected $unidadNegocio;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\UnidadNegocio", mappedBy="comerciales")
*/
protected $unidadesNegocioComercial;
public function __construct()
{
$this->user = new User();
$this->valoraciones = new ArrayCollection();
$this->unidadesNegocioComercial = new ArrayCollection();
$this->operaciones = new ArrayCollection();
$this->actividades = new ArrayCollection();
}
public function __toString(): string
{
return $this->getUser()?->getNombreCompleto()??$this->getUser()?->getUserIdentifier();
}
public function getId(): ?string
{
return $this->id;
}
public function getIDperseo(): ?string
{
return $this->IDperseo;
}
public function setIDperseo(string $IDperseo): self
{
$this->IDperseo = $IDperseo;
return $this;
}
public function getAvatar(): ?string
{
return $this->avatar;
}
public function setAvatar(?string $avatar): self
{
$this->avatar = $avatar;
return $this;
}
public function getDeletedAt(): ?\DateTimeInterface
{
return $this->deletedAt;
}
public function setDeletedAt(?\DateTimeInterface $deletedAt): self
{
$this->deletedAt = $deletedAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
// unset the owning side of the relation if necessary
if ($user === null && $this->user !== null) {
$this->user->setUsuario(null);
}
// set the owning side of the relation if necessary
if ($user !== null && $user->getUsuario() !== $this) {
$user->setUsuario($this);
}
$this->user = $user;
return $this;
}
public function getUnidadNegocioResponsable(): ?UnidadNegocio
{
return $this->unidadNegocioResponsable;
}
public function setUnidadNegocioResponsable(?UnidadNegocio $unidadNegocioResponsable): self
{
// unset the owning side of the relation if necessary
if ($unidadNegocioResponsable === null && $this->unidadNegocioResponsable !== null) {
$this->unidadNegocioResponsable->setResponsable(null);
}
// set the owning side of the relation if necessary
if ($unidadNegocioResponsable !== null && $unidadNegocioResponsable->getResponsable() !== $this) {
$unidadNegocioResponsable->setResponsable($this);
}
$this->unidadNegocioResponsable = $unidadNegocioResponsable;
return $this;
}
/**
* @return Collection|Valoracion[]
*/
public function getValoraciones(): Collection
{
return $this->valoraciones;
}
public function addValoracione(Valoracion $valoracione): self
{
if (!$this->valoraciones->contains($valoracione)) {
$this->valoraciones[] = $valoracione;
$valoracione->setUsuario($this);
}
return $this;
}
public function removeValoracione(Valoracion $valoracione): self
{
if ($this->valoraciones->removeElement($valoracione)) {
// set the owning side to null (unless already changed)
if ($valoracione->getUsuario() === $this) {
$valoracione->setUsuario(null);
}
}
return $this;
}
public function getUnidadNegocio(): ?UnidadNegocio
{
return $this->unidadNegocio;
}
public function setUnidadNegocio(?UnidadNegocio $unidadNegocio): self
{
$this->unidadNegocio = $unidadNegocio;
return $this;
}
/**
* @return Collection|UnidadNegocio[]
*/
public function getUnidadesNegocioComercial(): Collection
{
return $this->unidadesNegocioComercial;
}
public function addUnidadesNegocioComercial(UnidadNegocio $unidadesNegocioComercial): self
{
if (!$this->unidadesNegocioComercial->contains($unidadesNegocioComercial)) {
$this->unidadesNegocioComercial[] = $unidadesNegocioComercial;
$unidadesNegocioComercial->addComerciale($this);
}
return $this;
}
public function removeUnidadesNegocioComercial(UnidadNegocio $unidadesNegocioComercial): self
{
if ($this->unidadesNegocioComercial->removeElement($unidadesNegocioComercial)) {
$unidadesNegocioComercial->removeComerciale($this);
}
return $this;
}
/**
* @return Collection|Operacion[]
*/
public function getOperaciones(): Collection
{
return $this->operaciones;
}
public function addOperacione(Operacion $operacione): self
{
if (!$this->operaciones->contains($operacione)) {
$this->operaciones[] = $operacione;
$operacione->setUsuario($this);
}
return $this;
}
public function removeOperacione(Operacion $operacione): self
{
if ($this->operaciones->removeElement($operacione)) {
// set the owning side to null (unless already changed)
if ($operacione->getUsuario() === $this) {
$operacione->setUsuario(null);
}
}
return $this;
}
/**
* @return Collection<int, ActividadAbstract>
*/
public function getActividades(): Collection
{
return $this->actividades;
}
public function addActividade(ActividadAbstract $actividade): static
{
if (!$this->actividades->contains($actividade)) {
$this->actividades->add($actividade);
$actividade->setUsuario($this);
}
return $this;
}
public function removeActividade(ActividadAbstract $actividade): static
{
if ($this->actividades->removeElement($actividade)) {
// set the owning side to null (unless already changed)
if ($actividade->getUsuario() === $this) {
$actividade->setUsuario(null);
}
}
return $this;
}
}