<?phpnamespace App\Entity;use App\Repository\CanalRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Serializable;/** * @ORM\Entity(repositoryClass=CanalRepository::class) */class Canal implements Serializable{ /** * @ORM\Id() * @ORM\GeneratedValue() * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=255) */ private $nombre; /** * @ORM\ManyToMany(targetEntity=Proveedor::class, mappedBy="canales") */ private $proveedores; /** * @ORM\OneToMany(targetEntity=Contrato::class, mappedBy="canal") */ private $contratos; public function __construct() { $this->proveedores = new ArrayCollection(); $this->contratos = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getNombre(): ?string { return $this->nombre; } public function setNombre(string $nombre): self { $this->nombre = $nombre; return $this; } /** * @return Collection|Proveedor[] */ public function getProveedores(): Collection { return $this->proveedores; } public function addProveedore(Proveedor $proveedore): self { if (!$this->proveedores->contains($proveedore)) { $this->proveedores[] = $proveedore; } return $this; } public function removeProveedore(Proveedor $proveedore): self { if ($this->proveedores->contains($proveedore)) { $this->proveedores->removeElement($proveedore); } return $this; } /** * @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->setTipoLectura($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->getTipoLectura() === $this) { $contrato->setTipoLectura(null); } } return $this; } public function __toString() :?string { return $this->nombre; } /** * {@inheritdoc} */ public function serialize(): string { // add $this->salt too if you don't use Bcrypt or Argon2i return serialize([$this->id, $this->nombre, $this->contratos]); } /** * {@inheritdoc} */ public function unserialize($serialized): void { // add $this->salt too if you don't use Bcrypt or Argon2i [$this->id, $this->nombre, $this->contratos] = unserialize($serialized, ['allowed_classes' => false]); }}