<?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\Entity(repositoryClass="App\Repository\UnidadNegocioRepository")
* @ORM\Table(name="unidad_negocio", schema="perseo")
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
*/
class UnidadNegocio
{
/**
* @ORM\Id
* @ORM\Column(type="bigint", options={"unsigned":true})
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $nombre;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $descripcion;
/**
* @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\OneToMany(targetEntity="App\Entity\Valoracion", mappedBy="unidadNegocio")
*/
protected $valoraciones;
/**
* @ORM\OneToMany(targetEntity=\App\Entity\ActividadAbstract::class, mappedBy="unidadNegocio")
*/
private $actividades;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Usuario", mappedBy="unidadNegocio")
*/
protected $usuarios;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Operacion", mappedBy="unidadNegocio")
*/
protected $operaciones;
/**
*
* @ORM\JoinColumn(name="responsable_usuario_id", referencedColumnName="id", unique=true)
* @ORM\OneToOne(targetEntity="App\Entity\Usuario", inversedBy="unidadNegocioResponsable")
*/
protected $responsable;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Usuario", inversedBy="unidadesNegocioComercial")
* @ORM\JoinTable(
* name="unidad_negocio_has_comercial",
* joinColumns={@ORM\JoinColumn(name="unidad_negocio_id", referencedColumnName="id", nullable=false)},
* inverseJoinColumns={@ORM\JoinColumn(name="usuario_id", referencedColumnName="id", nullable=false)}
* )
*/
protected $comerciales;
public function __construct()
{
$this->valoraciones = new ArrayCollection();
$this->usuarios = new ArrayCollection();
$this->comerciales = new ArrayCollection();
$this->operaciones = new ArrayCollection();
$this->actividades = new ArrayCollection();
}
public function __toString(): string
{
return $this->getNombre()??'---';
}
public function getId(): ?string
{
return $this->id;
}
public function getNombre(): ?string
{
return $this->nombre;
}
public function setNombre(?string $nombre): self
{
$this->nombre = $nombre;
return $this;
}
public function getDescripcion(): ?string
{
return $this->descripcion;
}
public function setDescripcion(?string $descripcion): self
{
$this->descripcion = $descripcion;
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;
}
/**
* @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->setUnidadNegocio($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->getUnidadNegocio() === $this) {
$valoracione->setUnidadNegocio(null);
}
}
return $this;
}
/**
* @return Collection|Usuario[]
*/
public function getUsuarios(): Collection
{
return $this->usuarios;
}
public function addUsuario(Usuario $usuario): self
{
if (!$this->usuarios->contains($usuario)) {
$this->usuarios[] = $usuario;
$usuario->setUnidadNegocio($this);
}
return $this;
}
public function removeUsuario(Usuario $usuario): self
{
if ($this->usuarios->removeElement($usuario)) {
// set the owning side to null (unless already changed)
if ($usuario->getUnidadNegocio() === $this) {
$usuario->setUnidadNegocio(null);
}
}
return $this;
}
public function getResponsable(): ?Usuario
{
return $this->responsable;
}
public function setResponsable(?Usuario $responsable): self
{
$this->responsable = $responsable;
return $this;
}
/**
* @return Collection|Usuario[]
*/
public function getComerciales(): Collection
{
return $this->comerciales;
}
public function addComerciale(Usuario $comerciale): self
{
if (!$this->comerciales->contains($comerciale)) {
$this->comerciales[] = $comerciale;
}
return $this;
}
public function removeComerciale(Usuario $comerciale): self
{
$this->comerciales->removeElement($comerciale);
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->setUnidadNegocio($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->getUnidadNegocio() === $this) {
$operacione->setUnidadNegocio(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->setUnidadNegocio($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->getUnidadNegocio() === $this) {
$actividade->setUnidadNegocio(null);
}
}
return $this;
}
}