<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\FormuleRepository;
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: FormuleRepository::class)]
#[ApiResource()]
class Formule
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
#[Groups(['abonnement:read'])]
private $id;
#[ORM\Column(type: 'string', length: 100, nullable: true)]
#[Groups(['abonnement:read'])]
private $label;
#[ORM\Column(type: 'string', length: 100, nullable: true)]
#[Groups(['abonnement:read'])]
private $description;
#[ORM\Column(type: 'integer', nullable: true)]
#[Groups(['abonnement:read'])]
private $price;
#[ORM\OneToMany(mappedBy: 'formule', targetEntity: Reservation::class)]
private $reservations;
public function __construct()
{
$this->reservations = 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;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getPrice(): ?int
{
return $this->price;
}
public function setPrice(?int $price): self
{
$this->price = $price;
return $this;
}
/**
* @return Collection<int, Reservation>
*/
public function getReservations(): Collection
{
return $this->reservations;
}
public function addReservation(Reservation $reservation): self
{
if (!$this->reservations->contains($reservation)) {
$this->reservations[] = $reservation;
$reservation->setFormule($this);
}
return $this;
}
public function removeReservation(Reservation $reservation): self
{
if ($this->reservations->removeElement($reservation)) {
// set the owning side to null (unless already changed)
if ($reservation->getFormule() === $this) {
$reservation->setFormule(null);
}
}
return $this;
}
}