<?php
namespace App\Entity;
use App\Repository\ComercialRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=ComercialRepository::class)
*/
class Comercial
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $nif;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $nombre;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $apellido1;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $apellido2;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $telefono;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $email;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $codigoVendedor;
/**
* @ORM\OneToOne(targetEntity=User::class, inversedBy="comercial", cascade={"persist", "remove"})
*/
private $user;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $totalPuntos;
/**
* @ORM\OneToMany(targetEntity=Puntuacion::class, mappedBy="comercial", orphanRemoval=true)
*/
private $puntuacion;
/**
* @ORM\OneToMany(targetEntity=Contrato::class, mappedBy="seller")
*/
private $contratos;
/**
* @ORM\ManyToMany(targetEntity=Contrato::class, mappedBy="subseller")
*/
private $subContratos;
public function __construct()
{
$this->puntuacion = new ArrayCollection();
$this->contratos = new ArrayCollection();
$this->subContratos = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getNif(): ?string
{
return $this->nif;
}
public function setNif(?string $nif): self
{
$this->nif = $nif;
return $this;
}
public function getNombre(): ?string
{
return $this->nombre;
}
public function setNombre(?string $nombre): self
{
$this->nombre = $nombre;
return $this;
}
public function getApellido1(): ?string
{
return $this->apellido1;
}
public function setApellido1(?string $apellido1): self
{
$this->apellido1 = $apellido1;
return $this;
}
public function getApellido2(): ?string
{
return $this->apellido2;
}
public function setApellido2(?string $apellido2): self
{
$this->apellido2 = $apellido2;
return $this;
}
public function getTelefono(): ?string
{
return $this->telefono;
}
public function setTelefono(?string $telefono): self
{
$this->telefono = $telefono;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getCodigoVendedor(): ?string
{
return $this->codigoVendedor;
}
public function setCodigoVendedor(?string $codigoVendedor): self
{
$this->codigoVendedor = $codigoVendedor;
return $this;
}
public function getUser(): ?user
{
return $this->user;
}
public function setUser(?user $user): self
{
$this->user = $user;
return $this;
}
public function getTotalPuntos(): ?int
{
return $this->totalPuntos;
}
public function setTotalPuntos(?int $totalPuntos): self
{
$this->totalPuntos = $totalPuntos;
return $this;
}
/**
* @return Collection|Puntuacion[]
*/
public function getPuntuacion(): Collection
{
return $this->puntuacion;
}
public function addPuntuacion(Puntuacion $puntuacion): self
{
if (!$this->puntuacion->contains($puntuacion)) {
$this->puntuacion[] = $puntuacion;
$puntuacion->setComercial($this);
}
return $this;
}
public function removePuntuacion(Puntuacion $puntuacion): self
{
if ($this->puntuacion->contains($puntuacion)) {
$this->puntuacion->removeElement($puntuacion);
// set the owning side to null (unless already changed)
if ($puntuacion->getComercial() === $this) {
$puntuacion->setComercial(null);
}
}
return $this;
}
public function __toString() :string
{
$string=$this->nombre.' '.$this->apellido1;
if ($this->apellido2!=null)
$string.=' '.$this->apellido2;
return $string;
}
/**
* @return Collection|Contrato[]
*/
public function getContratos(): Collection
{
return $this->contratos;
}
public function addContrato(Contrato $contrato): self
{
if (!$this->contratos->contains($contrato)) {
$this->contratos[] = $contrato;
$contrato->setSeller($this);
}
return $this;
}
public function removeContrato(Contrato $contrato): self
{
if ($this->contratos->contains($contrato)) {
$this->contratos->removeElement($contrato);
// set the owning side to null (unless already changed)
if ($contrato->getSeller() === $this) {
$contrato->setSeller(null);
}
}
return $this;
}
/**
* @return Collection<int, Contrato>
*/
public function getSubContratos(): Collection
{
return $this->subContratos;
}
public function addSubContrato(Contrato $subContrato): self
{
if (!$this->subContratos->contains($subContrato)) {
$this->subContratos[] = $subContrato;
$subContrato->addSubseller($this);
}
return $this;
}
public function removeSubContrato(Contrato $subContrato): self
{
if ($this->subContratos->removeElement($subContrato)) {
$subContrato->removeSubseller($this);
}
return $this;
}
}