src/Entity/UnidadNegocio.php line 17

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