src/Entity/Formule.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\FormuleRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. #[ORM\Entity(repositoryClassFormuleRepository::class)]
  10. #[ApiResource()]
  11. class Formule
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column(type'integer')]
  16.     #[Groups(['abonnement:read'])]
  17.     private $id;
  18.     #[ORM\Column(type'string'length100nullabletrue)]
  19.     #[Groups(['abonnement:read'])]
  20.     private $label;
  21.     #[ORM\Column(type'string'length100nullabletrue)]
  22.     #[Groups(['abonnement:read'])]
  23.     private $description;
  24.     #[ORM\Column(type'integer'nullabletrue)]
  25.     #[Groups(['abonnement:read'])]
  26.     private $price;
  27.     #[ORM\OneToMany(mappedBy'formule'targetEntityReservation::class)]
  28.     private $reservations;
  29.     public function __construct()
  30.     {
  31.         $this->reservations = new ArrayCollection();
  32.     }
  33.     public function getId(): ?int
  34.     {
  35.         return $this->id;
  36.     }
  37.     public function getLabel(): ?string
  38.     {
  39.         return $this->label;
  40.     }
  41.     public function setLabel(?string $label): self
  42.     {
  43.         $this->label $label;
  44.         return $this;
  45.     }
  46.     public function getDescription(): ?string
  47.     {
  48.         return $this->description;
  49.     }
  50.     public function setDescription(?string $description): self
  51.     {
  52.         $this->description $description;
  53.         return $this;
  54.     }
  55.     public function getPrice(): ?int
  56.     {
  57.         return $this->price;
  58.     }
  59.     public function setPrice(?int $price): self
  60.     {
  61.         $this->price $price;
  62.         return $this;
  63.     }
  64.     /**
  65.      * @return Collection<int, Reservation>
  66.      */
  67.     public function getReservations(): Collection
  68.     {
  69.         return $this->reservations;
  70.     }
  71.     public function addReservation(Reservation $reservation): self
  72.     {
  73.         if (!$this->reservations->contains($reservation)) {
  74.             $this->reservations[] = $reservation;
  75.             $reservation->setFormule($this);
  76.         }
  77.         return $this;
  78.     }
  79.     public function removeReservation(Reservation $reservation): self
  80.     {
  81.         if ($this->reservations->removeElement($reservation)) {
  82.             // set the owning side to null (unless already changed)
  83.             if ($reservation->getFormule() === $this) {
  84.                 $reservation->setFormule(null);
  85.             }
  86.         }
  87.         return $this;
  88.     }
  89. }