<?php
namespace App\Entity;
use App\Repository\TypePrestationRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass=TypePrestationRepository::class)
*/
class TypePrestation
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups("location:read")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Groups("location:read")
*/
private $label;
/**
* @ORM\OneToMany(targetEntity=Product::class, mappedBy="typePrestation")
*/
private $products;
public function __construct()
{
$this->products = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(string $label): self
{
$this->label = $label;
return $this;
}
/**
* @return Collection|Product[]
*/
public function getProducts(): Collection
{
return $this->products;
}
public function addProduct(Product $product): self
{
if (!$this->products->contains($product)) {
$this->products[] = $product;
$product->setTypePrestation($this);
}
return $this;
}
public function removeProduct(Product $product): self
{
if ($this->products->removeElement($product)) {
// set the owning side to null (unless already changed)
if ($product->getTypePrestation() === $this) {
$product->setTypePrestation(null);
}
}
return $this;
}
public function __toString()
{
return $this->getLabel();
}
}