src/Entity/UnidadNegocio.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\Entity(repositoryClass="App\Repository\UnidadNegocioRepository")
  10.  * @ORM\Table(name="unidad_negocio", schema="perseo")
  11.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
  12.  */
  13. class UnidadNegocio
  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", nullable=true)
  23.      */
  24.     protected $nombre;
  25.     /**
  26.      * @ORM\Column(type="string", nullable=true)
  27.      */
  28.     protected $descripcion;
  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\OneToMany(targetEntity="App\Entity\Valoracion", mappedBy="unidadNegocio")
  45.      */
  46.     protected $valoraciones;
  47.     /**
  48.      * @ORM\OneToMany(targetEntity=\App\Entity\ActividadAbstract::class, mappedBy="unidadNegocio")
  49.      */
  50.     private $actividades;
  51.     /**
  52.      * @ORM\OneToMany(targetEntity="App\Entity\Usuario", mappedBy="unidadNegocio")
  53.      */
  54.     protected $usuarios;
  55.     /**
  56.      * @ORM\OneToMany(targetEntity="App\Entity\Operacion", mappedBy="unidadNegocio")
  57.      */
  58.     protected $operaciones;
  59.     /**
  60.      *
  61.      * @ORM\JoinColumn(name="responsable_usuario_id", referencedColumnName="id", unique=true)
  62.      * @ORM\OneToOne(targetEntity="App\Entity\Usuario", inversedBy="unidadNegocioResponsable")
  63.      */
  64.     protected $responsable;
  65.     /**
  66.      * @ORM\ManyToMany(targetEntity="App\Entity\Usuario", inversedBy="unidadesNegocioComercial")
  67.      * @ORM\JoinTable(
  68.      *     name="unidad_negocio_has_comercial",
  69.      *     joinColumns={@ORM\JoinColumn(name="unidad_negocio_id", referencedColumnName="id", nullable=false)},
  70.      *     inverseJoinColumns={@ORM\JoinColumn(name="usuario_id", referencedColumnName="id", nullable=false)}
  71.      * )
  72.      */
  73.     protected $comerciales;
  74.     public function __construct()
  75.     {
  76.         $this->valoraciones = new ArrayCollection();
  77.         $this->usuarios = new ArrayCollection();
  78.         $this->comerciales = new ArrayCollection();
  79.         $this->operaciones = new ArrayCollection();
  80.         $this->actividades = new ArrayCollection();
  81.     }
  82.     public function __toString(): string
  83.     {
  84.         return $this->getNombre()??'---';
  85.     }
  86.     public function getId(): ?string
  87.     {
  88.         return $this->id;
  89.     }
  90.     public function getNombre(): ?string
  91.     {
  92.         return $this->nombre;
  93.     }
  94.     public function setNombre(?string $nombre): self
  95.     {
  96.         $this->nombre $nombre;
  97.         return $this;
  98.     }
  99.     public function getDescripcion(): ?string
  100.     {
  101.         return $this->descripcion;
  102.     }
  103.     public function setDescripcion(?string $descripcion): self
  104.     {
  105.         $this->descripcion $descripcion;
  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.     /**
  136.      * @return Collection|Valoracion[]
  137.      */
  138.     public function getValoraciones(): Collection
  139.     {
  140.         return $this->valoraciones;
  141.     }
  142.     public function addValoracione(Valoracion $valoracione): self
  143.     {
  144.         if (!$this->valoraciones->contains($valoracione)) {
  145.             $this->valoraciones[] = $valoracione;
  146.             $valoracione->setUnidadNegocio($this);
  147.         }
  148.         return $this;
  149.     }
  150.     public function removeValoracione(Valoracion $valoracione): self
  151.     {
  152.         if ($this->valoraciones->removeElement($valoracione)) {
  153.             // set the owning side to null (unless already changed)
  154.             if ($valoracione->getUnidadNegocio() === $this) {
  155.                 $valoracione->setUnidadNegocio(null);
  156.             }
  157.         }
  158.         return $this;
  159.     }
  160.     /**
  161.      * @return Collection|Usuario[]
  162.      */
  163.     public function getUsuarios(): Collection
  164.     {
  165.         return $this->usuarios;
  166.     }
  167.     public function addUsuario(Usuario $usuario): self
  168.     {
  169.         if (!$this->usuarios->contains($usuario)) {
  170.             $this->usuarios[] = $usuario;
  171.             $usuario->setUnidadNegocio($this);
  172.         }
  173.         return $this;
  174.     }
  175.     public function removeUsuario(Usuario $usuario): self
  176.     {
  177.         if ($this->usuarios->removeElement($usuario)) {
  178.             // set the owning side to null (unless already changed)
  179.             if ($usuario->getUnidadNegocio() === $this) {
  180.                 $usuario->setUnidadNegocio(null);
  181.             }
  182.         }
  183.         return $this;
  184.     }
  185.     public function getResponsable(): ?Usuario
  186.     {
  187.         return $this->responsable;
  188.     }
  189.     public function setResponsable(?Usuario $responsable): self
  190.     {
  191.         $this->responsable $responsable;
  192.         return $this;
  193.     }
  194.     /**
  195.      * @return Collection|Usuario[]
  196.      */
  197.     public function getComerciales(): Collection
  198.     {
  199.         return $this->comerciales;
  200.     }
  201.     public function addComerciale(Usuario $comerciale): self
  202.     {
  203.         if (!$this->comerciales->contains($comerciale)) {
  204.             $this->comerciales[] = $comerciale;
  205.         }
  206.         return $this;
  207.     }
  208.     public function removeComerciale(Usuario $comerciale): self
  209.     {
  210.         $this->comerciales->removeElement($comerciale);
  211.         return $this;
  212.     }
  213.     /**
  214.      * @return Collection|Operacion[]
  215.      */
  216.     public function getOperaciones(): Collection
  217.     {
  218.         return $this->operaciones;
  219.     }
  220.     public function addOperacione(Operacion $operacione): self
  221.     {
  222.         if (!$this->operaciones->contains($operacione)) {
  223.             $this->operaciones[] = $operacione;
  224.             $operacione->setUnidadNegocio($this);
  225.         }
  226.         return $this;
  227.     }
  228.     public function removeOperacione(Operacion $operacione): self
  229.     {
  230.         if ($this->operaciones->removeElement($operacione)) {
  231.             // set the owning side to null (unless already changed)
  232.             if ($operacione->getUnidadNegocio() === $this) {
  233.                 $operacione->setUnidadNegocio(null);
  234.             }
  235.         }
  236.         return $this;
  237.     }
  238.     /**
  239.      * @return Collection<int, ActividadAbstract>
  240.      */
  241.     public function getActividades(): Collection
  242.     {
  243.         return $this->actividades;
  244.     }
  245.     public function addActividade(ActividadAbstract $actividade): static
  246.     {
  247.         if (!$this->actividades->contains($actividade)) {
  248.             $this->actividades->add($actividade);
  249.             $actividade->setUnidadNegocio($this);
  250.         }
  251.         return $this;
  252.     }
  253.     public function removeActividade(ActividadAbstract $actividade): static
  254.     {
  255.         if ($this->actividades->removeElement($actividade)) {
  256.             // set the owning side to null (unless already changed)
  257.             if ($actividade->getUnidadNegocio() === $this) {
  258.                 $actividade->setUnidadNegocio(null);
  259.             }
  260.         }
  261.         return $this;
  262.     }
  263. }