<?php
namespace App\Entity;
use App\Repository\ModalidadRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=ModalidadRepository::class)
*/
class Modalidad
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $nombre;
/**
* @ORM\OneToMany(targetEntity=Producto::class, mappedBy="modalidad")
*/
private $productos;
public function __construct()
{
$this->productos = 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|Producto[]
*/
public function getProductos(): Collection
{
return $this->productos;
}
public function addProducto(Producto $producto): self
{
if (!$this->productos->contains($producto)) {
$this->productos[] = $producto;
$producto->setModalidad($this);
}
return $this;
}
public function removeProducto(Producto $producto): self
{
if ($this->productos->contains($producto)) {
$this->productos->removeElement($producto);
// set the owning side to null (unless already changed)
if ($producto->getModalidad() === $this) {
$producto->setModalidad(null);
}
}
return $this;
}
public function __toString():?string
{
return $this->nombre;
}
}