src/Entity/Proveedor.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ProveedorRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Serializable;
  8. /**
  9.  * @ORM\Entity(repositoryClass=ProveedorRepository::class)
  10.  */
  11. class Proveedor
  12. {
  13.     /**
  14.      * @ORM\Id()
  15.      * @ORM\GeneratedValue()
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="string", length=255)
  21.      */
  22.     private $nombre;
  23.     /**
  24.      * @ORM\OneToMany(targetEntity=ProductoProveedor::class, mappedBy="proveedor")
  25.      */
  26.     private $productoProveedors;
  27.     /**
  28.      * @ORM\OneToMany(targetEntity=Contrato::class, mappedBy="proveedor")
  29.      */
  30.     private $contratos;
  31.     /**
  32.      * @ORM\ManyToMany(targetEntity=Canal::class, inversedBy="proveedores")
  33.      */
  34.     private $canales;
  35.     public function __construct()
  36.     {
  37.         $this->productoProveedors = new ArrayCollection();
  38.         $this->canales = new ArrayCollection();
  39.     }
  40.     public function getId(): ?int
  41.     {
  42.         return $this->id;
  43.     }
  44.     public function getNombre(): ?string
  45.     {
  46.         return $this->nombre;
  47.     }
  48.     public function setNombre(string $nombre): self
  49.     {
  50.         $this->nombre $nombre;
  51.         return $this;
  52.     }
  53.     /**
  54.      * @return Collection|ProductoProveedor[]
  55.      */
  56.     public function getProductoProveedors(): Collection
  57.     {
  58.         return $this->productoProveedors;
  59.     }
  60.     public function addProductoProveedor(ProductoProveedor $productoProveedor): self
  61.     {
  62.         if (!$this->productoProveedors->contains($productoProveedor)) {
  63.             $this->productoProveedors[] = $productoProveedor;
  64.             $productoProveedor->setProveedor($this);
  65.         }
  66.         return $this;
  67.     }
  68.     public function removeProductoProveedor(ProductoProveedor $productoProveedor): self
  69.     {
  70.         if ($this->productoProveedors->contains($productoProveedor)) {
  71.             $this->productoProveedors->removeElement($productoProveedor);
  72.             // set the owning side to null (unless already changed)
  73.             if ($productoProveedor->getProveedor() === $this) {
  74.                 $productoProveedor->setProveedor(null);
  75.             }
  76.         }
  77.         return $this;
  78.     }
  79.     /**
  80.      * @return Collection|Contrato[]
  81.      */
  82.     public function getContratos(): Collection
  83.     {
  84.         return $this->contratos;
  85.     }
  86.     public function addContrato(Contrato $contrato): self
  87.     {
  88.         if (!$this->contratos->contains($contrato)) {
  89.             $this->contratos[] = $contrato;
  90.             $contrato->setProveedor($this);
  91.         }
  92.         return $this;
  93.     }
  94.     public function removeContrato(Contrato $contrato): self
  95.     {
  96.         if ($this->contratos->contains($contrato)) {
  97.             $this->contratos->removeElement($contrato);
  98.             // set the owning side to null (unless already changed)
  99.             if ($contrato->getProveedor() === $this) {
  100.                 $contrato->setProveedor(null);
  101.             }
  102.         }
  103.         return $this;
  104.     }
  105.     /**
  106.      * @return Collection|Canal[]
  107.      */
  108.     public function getCanales(): Collection
  109.     {
  110.         return $this->canales;
  111.     }
  112.     public function addCanal(Canal $canal): self
  113.     {
  114.         if (!$this->canales->contains($canal)) {
  115.             $this->canales[] = $canal;
  116.             $canal->addProveedore($this);
  117.         }
  118.         return $this;
  119.     }
  120.     public function removeCanal(Canal $canal): self
  121.     {
  122.         if ($this->canales->contains($canal)) {
  123.             $this->canales->removeElement($canal);
  124.             $canal->removeProveedore($this);
  125.         }
  126.         return $this;
  127.     }
  128.     public function __toString():?string
  129.     {
  130.         return $this->nombre;
  131.     }
  132. }