<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\TypeReservationRepository;
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: TypeReservationRepository::class)]
#[ApiResource()]
class TypeReservation
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
#[Groups(['reservation:read','price:read'])]
private $id;
#[ORM\Column(type: 'string', length: 60, nullable: true)]
#[Groups(['reservation:read','price:read'])]
private $label;
#[ORM\OneToMany(mappedBy: 'typeReservation', targetEntity: Price::class)]
private $prices;
public function __construct()
{
$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, Price>
*/
public function getPrices(): Collection
{
return $this->prices;
}
public function addPrice(Price $price): self
{
if (!$this->prices->contains($price)) {
$this->prices[] = $price;
$price->setTypeReservation($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->getTypeReservation() === $this) {
$price->setTypeReservation(null);
}
}
return $this;
}
}