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