<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\TypePitchRepository;
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: TypePitchRepository::class)]
#[ApiResource()]
class TypePitch
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[Groups(['pitch:read','price:read'])]
#[ORM\Column(type: 'integer')]
private $id;
#[Groups(['pitch:read','price:read'])]
#[ORM\Column(type: 'string', length: 100)]
private $label;
#[ORM\OneToMany(mappedBy: 'typePitch', targetEntity: Pitch::class)]
private $pitches;
#[Groups(['pitch:read','price:read'])]
#[ORM\Column(type: 'string', length: 20,unique:true)]
private $code;
#[ORM\OneToMany(mappedBy: 'typePitch', targetEntity: Price::class)]
private $prices;
public function __construct()
{
$this->pitches = new ArrayCollection();
$this->prices = 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<int, Pitch>
*/
public function getPitches(): Collection
{
return $this->pitches;
}
public function addPitch(Pitch $pitch): self
{
if (!$this->pitches->contains($pitch)) {
$this->pitches[] = $pitch;
$pitch->setTypePitch($this);
}
return $this;
}
public function removePitch(Pitch $pitch): self
{
if ($this->pitches->removeElement($pitch)) {
// set the owning side to null (unless already changed)
if ($pitch->getTypePitch() === $this) {
$pitch->setTypePitch(null);
}
}
return $this;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(string $code): self
{
$this->code = $code;
return $this;
}
/**
* @return Collection<int, Price>
*/
public function getPrices(): Collection
{
return $this->prices;
}
public function addPrice(Price $price): self
{
if (!$this->prices->contains($price)) {
$this->prices[] = $price;
$price->setTypePitch($this);
}
return $this;
}
public function removePrice(Price $price): self
{
if ($this->prices->removeElement($price)) {
// set the owning side to null (unless already changed)
if ($price->getTypePitch() === $this) {
$price->setTypePitch(null);
}
}
return $this;
}
}