src/Entity/Comercial.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ComercialRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=ComercialRepository::class)
  9.  */
  10. class Comercial
  11. {
  12.     /**
  13.      * @ORM\Id()
  14.      * @ORM\GeneratedValue()
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=255, nullable=true)
  20.      */
  21.     private $nif;
  22.     /**
  23.      * @ORM\Column(type="string", length=255, nullable=true)
  24.      */
  25.     private $nombre;
  26.     /**
  27.      * @ORM\Column(type="string", length=255, nullable=true)
  28.      */
  29.     private $apellido1;
  30.     /**
  31.      * @ORM\Column(type="string", length=255, nullable=true)
  32.      */
  33.     private $apellido2;
  34.     /**
  35.      * @ORM\Column(type="string", length=255, nullable=true)
  36.      */
  37.     private $telefono;
  38.     /**
  39.      * @ORM\Column(type="string", length=255, nullable=true)
  40.      */
  41.     private $email;
  42.     /**
  43.      * @ORM\Column(type="string", length=255, nullable=true)
  44.      */
  45.     private $codigoVendedor;
  46.     /**
  47.      * @ORM\OneToOne(targetEntity=User::class, inversedBy="comercial", cascade={"persist", "remove"})
  48.      */
  49.     private $user;
  50.     /**
  51.      * @ORM\Column(type="integer", nullable=true)
  52.      */
  53.     private $totalPuntos;
  54.     /**
  55.      * @ORM\OneToMany(targetEntity=Puntuacion::class, mappedBy="comercial", orphanRemoval=true)
  56.      */
  57.     private $puntuacion;
  58.     /**
  59.      * @ORM\OneToMany(targetEntity=Contrato::class, mappedBy="seller")
  60.      */
  61.     private $contratos;
  62.     /**
  63.      * @ORM\ManyToMany(targetEntity=Contrato::class, mappedBy="subseller")
  64.      */
  65.     private $subContratos;
  66.     public function __construct()
  67.     {
  68.         $this->puntuacion = new ArrayCollection();
  69.         $this->contratos = new ArrayCollection();
  70.         $this->subContratos = new ArrayCollection();
  71.     }
  72.     public function getId(): ?int
  73.     {
  74.         return $this->id;
  75.     }
  76.     public function getNif(): ?string
  77.     {
  78.         return $this->nif;
  79.     }
  80.     public function setNif(?string $nif): self
  81.     {
  82.         $this->nif $nif;
  83.         return $this;
  84.     }
  85.     public function getNombre(): ?string
  86.     {
  87.         return $this->nombre;
  88.     }
  89.     public function setNombre(?string $nombre): self
  90.     {
  91.         $this->nombre $nombre;
  92.         return $this;
  93.     }
  94.     public function getApellido1(): ?string
  95.     {
  96.         return $this->apellido1;
  97.     }
  98.     public function setApellido1(?string $apellido1): self
  99.     {
  100.         $this->apellido1 $apellido1;
  101.         return $this;
  102.     }
  103.     public function getApellido2(): ?string
  104.     {
  105.         return $this->apellido2;
  106.     }
  107.     public function setApellido2(?string $apellido2): self
  108.     {
  109.         $this->apellido2 $apellido2;
  110.         return $this;
  111.     }
  112.     public function getTelefono(): ?string
  113.     {
  114.         return $this->telefono;
  115.     }
  116.     public function setTelefono(?string $telefono): self
  117.     {
  118.         $this->telefono $telefono;
  119.         return $this;
  120.     }
  121.     public function getEmail(): ?string
  122.     {
  123.         return $this->email;
  124.     }
  125.     public function setEmail(?string $email): self
  126.     {
  127.         $this->email $email;
  128.         return $this;
  129.     }
  130.     public function getCodigoVendedor(): ?string
  131.     {
  132.         return $this->codigoVendedor;
  133.     }
  134.     public function setCodigoVendedor(?string $codigoVendedor): self
  135.     {
  136.         $this->codigoVendedor $codigoVendedor;
  137.         return $this;
  138.     }
  139.     public function getUser(): ?user
  140.     {
  141.         return $this->user;
  142.     }
  143.     public function setUser(?user $user): self
  144.     {
  145.         $this->user $user;
  146.         return $this;
  147.     }
  148.     public function getTotalPuntos(): ?int
  149.     {
  150.         return $this->totalPuntos;
  151.     }
  152.     public function setTotalPuntos(?int $totalPuntos): self
  153.     {
  154.         $this->totalPuntos $totalPuntos;
  155.         return $this;
  156.     }
  157.     /**
  158.      * @return Collection|Puntuacion[]
  159.      */
  160.     public function getPuntuacion(): Collection
  161.     {
  162.         return $this->puntuacion;
  163.     }
  164.     public function addPuntuacion(Puntuacion $puntuacion): self
  165.     {
  166.         if (!$this->puntuacion->contains($puntuacion)) {
  167.             $this->puntuacion[] = $puntuacion;
  168.             $puntuacion->setComercial($this);
  169.         }
  170.         return $this;
  171.     }
  172.     public function removePuntuacion(Puntuacion $puntuacion): self
  173.     {
  174.         if ($this->puntuacion->contains($puntuacion)) {
  175.             $this->puntuacion->removeElement($puntuacion);
  176.             // set the owning side to null (unless already changed)
  177.             if ($puntuacion->getComercial() === $this) {
  178.                 $puntuacion->setComercial(null);
  179.             }
  180.         }
  181.         return $this;
  182.     }
  183.     public function __toString() :string
  184.     {
  185.         $string=$this->nombre.' '.$this->apellido1;
  186.         if ($this->apellido2!=null)
  187.             $string.=' '.$this->apellido2;
  188.         return $string;
  189.     }
  190.     /**
  191.      * @return Collection|Contrato[]
  192.      */
  193.     public function getContratos(): Collection
  194.     {
  195.         return $this->contratos;
  196.     }
  197.     public function addContrato(Contrato $contrato): self
  198.     {
  199.         if (!$this->contratos->contains($contrato)) {
  200.             $this->contratos[] = $contrato;
  201.             $contrato->setSeller($this);
  202.         }
  203.         return $this;
  204.     }
  205.     public function removeContrato(Contrato $contrato): self
  206.     {
  207.         if ($this->contratos->contains($contrato)) {
  208.             $this->contratos->removeElement($contrato);
  209.             // set the owning side to null (unless already changed)
  210.             if ($contrato->getSeller() === $this) {
  211.                 $contrato->setSeller(null);
  212.             }
  213.         }
  214.         return $this;
  215.     }
  216.     /**
  217.      * @return Collection<int, Contrato>
  218.      */
  219.     public function getSubContratos(): Collection
  220.     {
  221.         return $this->subContratos;
  222.     }
  223.     public function addSubContrato(Contrato $subContrato): self
  224.     {
  225.         if (!$this->subContratos->contains($subContrato)) {
  226.             $this->subContratos[] = $subContrato;
  227.             $subContrato->addSubseller($this);
  228.         }
  229.         return $this;
  230.     }
  231.     public function removeSubContrato(Contrato $subContrato): self
  232.     {
  233.         if ($this->subContratos->removeElement($subContrato)) {
  234.             $subContrato->removeSubseller($this);
  235.         }
  236.         return $this;
  237.     }
  238. }