src/Entity/Canal.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CanalRepository;
  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=CanalRepository::class)
  10.  */
  11. class Canal implements Serializable
  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\ManyToMany(targetEntity=Proveedor::class, mappedBy="canales")
  25.      */
  26.     private $proveedores;
  27.     /**
  28.      * @ORM\OneToMany(targetEntity=Contrato::class, mappedBy="canal")
  29.      */
  30.     private $contratos;
  31.     public function __construct()
  32.     {
  33.         $this->proveedores = new ArrayCollection();
  34.         $this->contratos = new ArrayCollection();
  35.     }
  36.     public function getId(): ?int
  37.     {
  38.         return $this->id;
  39.     }
  40.     public function getNombre(): ?string
  41.     {
  42.         return $this->nombre;
  43.     }
  44.     public function setNombre(string $nombre): self
  45.     {
  46.         $this->nombre $nombre;
  47.         return $this;
  48.     }
  49.     /**
  50.      * @return Collection|Proveedor[]
  51.      */
  52.     public function getProveedores(): Collection
  53.     {
  54.         return $this->proveedores;
  55.     }
  56.     public function addProveedore(Proveedor $proveedore): self
  57.     {
  58.         if (!$this->proveedores->contains($proveedore)) {
  59.             $this->proveedores[] = $proveedore;
  60.         }
  61.         return $this;
  62.     }
  63.     public function removeProveedore(Proveedor $proveedore): self
  64.     {
  65.         if ($this->proveedores->contains($proveedore)) {
  66.             $this->proveedores->removeElement($proveedore);
  67.         }
  68.         return $this;
  69.     }
  70.     /**
  71.      * @return Collection|Contrato[]
  72.      */
  73.     public function getContratos(): Collection
  74.     {
  75.         return $this->contratos;
  76.     }
  77.     public function addContrato(Contrato $contrato): self
  78.     {
  79.         if (!$this->contratos->contains($contrato)) {
  80.             $this->contratos[] = $contrato;
  81.             $contrato->setTipoLectura($this);
  82.         }
  83.         return $this;
  84.     }
  85.     public function removeContrato(Contrato $contrato): self
  86.     {
  87.         if ($this->contratos->contains($contrato)) {
  88.             $this->contratos->removeElement($contrato);
  89.             // set the owning side to null (unless already changed)
  90.             if ($contrato->getTipoLectura() === $this) {
  91.                 $contrato->setTipoLectura(null);
  92.             }
  93.         }
  94.         return $this;
  95.     }
  96.     public function __toString() :?string
  97.     {
  98.         return $this->nombre;
  99.     }
  100.     /**
  101.      * {@inheritdoc}
  102.      */
  103.     public function serialize(): string
  104.     {
  105.         // add $this->salt too if you don't use Bcrypt or Argon2i
  106.         return serialize([$this->id$this->nombre$this->contratos]);
  107.     }
  108.     /**
  109.      * {@inheritdoc}
  110.      */
  111.     public function unserialize($serialized): void
  112.     {
  113.         // add $this->salt too if you don't use Bcrypt or Argon2i
  114.         [$this->id$this->nombre$this->contratos] = unserialize($serialized, ['allowed_classes' => false]);
  115.     }
  116. }