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")
  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="boolean", nullable=true, options={"default":1})
  31.      */
  32.     private $active;
  33.     /**
  34.      * @ORM\Column(type="datetime", nullable=true, name="deleted_at")
  35.      */
  36.     protected $deletedAt;
  37.     /**
  38.      * @ORM\Column(type="datetime", nullable=false, name="updated_at", options={"default":"2022-01-01 00:00:00"})
  39.      * @Gedmo\Timestampable(on="update")
  40.      */
  41.     protected $updatedAt;
  42.     /**
  43.      * @ORM\Column(type="datetime", nullable=false, name="created_at", options={"default":"2022-01-01 00:00:00"})
  44.      * @Gedmo\Timestampable(on="create")
  45.      */
  46.     protected $createdAt;
  47.     /**
  48.      * @ORM\OneToMany(targetEntity="App\Entity\Valoracion", mappedBy="unidadNegocio")
  49.      */
  50.     protected $valoraciones;
  51.     /**
  52.      * @ORM\OneToMany(targetEntity=\App\Entity\ActividadAbstract::class, mappedBy="unidadNegocio")
  53.      */
  54.     private $actividades;
  55.     /**
  56.      * @ORM\ManyToOne(targetEntity=\App\Entity\Empresa::class, inversedBy="unidadNegocios")
  57.      * @ORM\JoinColumn(name="empresa_id", referencedColumnName="id", nullable=false)
  58.      */
  59.     private $empresa;
  60.     /**
  61.      * @ORM\OneToMany(targetEntity="App\Entity\Usuario", mappedBy="unidadNegocio")
  62.      */
  63.     protected $usuarios;
  64.     /**
  65.      * @ORM\OneToMany(targetEntity="App\Entity\Operacion", mappedBy="unidadNegocio")
  66.      */
  67.     protected $operaciones;
  68.     /**
  69.      *
  70.      * @ORM\JoinColumn(name="responsable_usuario_id", referencedColumnName="id", unique=true)
  71.      * @ORM\OneToOne(targetEntity="App\Entity\Usuario", inversedBy="unidadNegocioResponsable")
  72.      */
  73.     protected $responsable;
  74.     /**
  75.      * @ORM\ManyToMany(targetEntity="App\Entity\Usuario", inversedBy="unidadesNegocioComercial")
  76.      * @ORM\JoinTable(
  77.      *     name="unidad_negocio_has_comercial",
  78.      *     joinColumns={@ORM\JoinColumn(name="unidad_negocio_id", referencedColumnName="id", nullable=false)},
  79.      *     inverseJoinColumns={@ORM\JoinColumn(name="usuario_id", referencedColumnName="id", nullable=false)}
  80.      * )
  81.      */
  82.     protected $comerciales;
  83.     public function __construct()
  84.     {
  85.         $this->valoraciones = new ArrayCollection();
  86.         $this->usuarios = new ArrayCollection();
  87.         $this->comerciales = new ArrayCollection();
  88.         $this->operaciones = new ArrayCollection();
  89.         $this->actividades = new ArrayCollection();
  90.     }
  91.     public function __toString(): string
  92.     {
  93.         return $this->getEmpresa()->getCod() . ' - ' $this->getNombre();
  94.     }
  95.     public function getId(): ?string
  96.     {
  97.         return $this->id;
  98.     }
  99.     public function getNombre(): ?string
  100.     {
  101.         return $this->nombre;
  102.     }
  103.     public function setNombre(?string $nombre): self
  104.     {
  105.         $this->nombre $nombre;
  106.         return $this;
  107.     }
  108.     public function getDescripcion(): ?string
  109.     {
  110.         return $this->descripcion;
  111.     }
  112.     public function setDescripcion(?string $descripcion): self
  113.     {
  114.         $this->descripcion $descripcion;
  115.         return $this;
  116.     }
  117.     public function getDeletedAt(): ?\DateTimeInterface
  118.     {
  119.         return $this->deletedAt;
  120.     }
  121.     public function setDeletedAt(?\DateTimeInterface $deletedAt): self
  122.     {
  123.         $this->deletedAt $deletedAt;
  124.         return $this;
  125.     }
  126.     public function getUpdatedAt(): ?\DateTimeInterface
  127.     {
  128.         return $this->updatedAt;
  129.     }
  130.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  131.     {
  132.         $this->updatedAt $updatedAt;
  133.         return $this;
  134.     }
  135.     public function getCreatedAt(): ?\DateTimeInterface
  136.     {
  137.         return $this->createdAt;
  138.     }
  139.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  140.     {
  141.         $this->createdAt $createdAt;
  142.         return $this;
  143.     }
  144.     /**
  145.      * @return Collection|Valoracion[]
  146.      */
  147.     public function getValoraciones(): Collection
  148.     {
  149.         return $this->valoraciones;
  150.     }
  151.     public function addValoracione(Valoracion $valoracione): self
  152.     {
  153.         if (!$this->valoraciones->contains($valoracione)) {
  154.             $this->valoraciones[] = $valoracione;
  155.             $valoracione->setUnidadNegocio($this);
  156.         }
  157.         return $this;
  158.     }
  159.     public function removeValoracione(Valoracion $valoracione): self
  160.     {
  161.         if ($this->valoraciones->removeElement($valoracione)) {
  162.             // set the owning side to null (unless already changed)
  163.             if ($valoracione->getUnidadNegocio() === $this) {
  164.                 $valoracione->setUnidadNegocio(null);
  165.             }
  166.         }
  167.         return $this;
  168.     }
  169.     /**
  170.      * @return Collection|Usuario[]
  171.      */
  172.     public function getUsuarios(): Collection
  173.     {
  174.         return $this->usuarios;
  175.     }
  176.     public function addUsuario(Usuario $usuario): self
  177.     {
  178.         if (!$this->usuarios->contains($usuario)) {
  179.             $this->usuarios[] = $usuario;
  180.             $usuario->setUnidadNegocio($this);
  181.         }
  182.         return $this;
  183.     }
  184.     public function removeUsuario(Usuario $usuario): self
  185.     {
  186.         if ($this->usuarios->removeElement($usuario)) {
  187.             // set the owning side to null (unless already changed)
  188.             if ($usuario->getUnidadNegocio() === $this) {
  189.                 $usuario->setUnidadNegocio(null);
  190.             }
  191.         }
  192.         return $this;
  193.     }
  194.     public function getResponsable(): ?Usuario
  195.     {
  196.         return $this->responsable;
  197.     }
  198.     public function setResponsable(?Usuario $responsable): self
  199.     {
  200.         $this->responsable $responsable;
  201.         return $this;
  202.     }
  203.     /**
  204.      * @return Collection|Usuario[]
  205.      */
  206.     public function getComerciales(): Collection
  207.     {
  208.         return $this->comerciales;
  209.     }
  210.     public function addComerciale(Usuario $comerciale): self
  211.     {
  212.         if (!$this->comerciales->contains($comerciale)) {
  213.             $this->comerciales[] = $comerciale;
  214.         }
  215.         return $this;
  216.     }
  217.     public function removeComerciale(Usuario $comerciale): self
  218.     {
  219.         $this->comerciales->removeElement($comerciale);
  220.         return $this;
  221.     }
  222.     /**
  223.      * @return Collection|Operacion[]
  224.      */
  225.     public function getOperaciones(): Collection
  226.     {
  227.         return $this->operaciones;
  228.     }
  229.     public function addOperacione(Operacion $operacione): self
  230.     {
  231.         if (!$this->operaciones->contains($operacione)) {
  232.             $this->operaciones[] = $operacione;
  233.             $operacione->setUnidadNegocio($this);
  234.         }
  235.         return $this;
  236.     }
  237.     public function removeOperacione(Operacion $operacione): self
  238.     {
  239.         if ($this->operaciones->removeElement($operacione)) {
  240.             // set the owning side to null (unless already changed)
  241.             if ($operacione->getUnidadNegocio() === $this) {
  242.                 $operacione->setUnidadNegocio(null);
  243.             }
  244.         }
  245.         return $this;
  246.     }
  247.     /**
  248.      * @return Collection<int, ActividadAbstract>
  249.      */
  250.     public function getActividades(): Collection
  251.     {
  252.         return $this->actividades;
  253.     }
  254.     public function addActividade(ActividadAbstract $actividade): static
  255.     {
  256.         if (!$this->actividades->contains($actividade)) {
  257.             $this->actividades->add($actividade);
  258.             $actividade->setUnidadNegocio($this);
  259.         }
  260.         return $this;
  261.     }
  262.     public function removeActividade(ActividadAbstract $actividade): static
  263.     {
  264.         if ($this->actividades->removeElement($actividade)) {
  265.             // set the owning side to null (unless already changed)
  266.             if ($actividade->getUnidadNegocio() === $this) {
  267.                 $actividade->setUnidadNegocio(null);
  268.             }
  269.         }
  270.         return $this;
  271.     }
  272.     public function isActive(): ?bool
  273.     {
  274.         return $this->active;
  275.     }
  276.     public function setActive(?bool $active): static
  277.     {
  278.         $this->active $active;
  279.         return $this;
  280.     }
  281.     public function getEmpresa(): ?Empresa
  282.     {
  283.         return $this->empresa;
  284.     }
  285.     public function setEmpresa(?Empresa $empresa): static
  286.     {
  287.         $this->empresa $empresa;
  288.         return $this;
  289.     }
  290. }