src/Entity/TypeReservation.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\TypeReservationRepository;
  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(repositoryClassTypeReservationRepository::class)]
  10. #[ApiResource()]
  11. class TypeReservation
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column(type'integer')]
  16.     #[Groups(['reservation:read','price:read'])]
  17.     private $id;
  18.     #[ORM\Column(type'string'length60nullabletrue)]
  19.     #[Groups(['reservation:read','price:read'])]
  20.     private $label;
  21.     #[ORM\OneToMany(mappedBy'typeReservation'targetEntityPrice::class)]
  22.     private $prices;
  23.     public function __construct()
  24.     {
  25.         $this->prices = new ArrayCollection();
  26.     }
  27.     public function getId(): ?int
  28.     {
  29.         return $this->id;
  30.     }
  31.     public function getLabel(): ?string
  32.     {
  33.         return $this->label;
  34.     }
  35.     public function setLabel(?string $label): self
  36.     {
  37.         $this->label $label;
  38.         return $this;
  39.     }
  40.     /**
  41.      * @return Collection<int, Price>
  42.      */
  43.     public function getPrices(): Collection
  44.     {
  45.         return $this->prices;
  46.     }
  47.     public function addPrice(Price $price): self
  48.     {
  49.         if (!$this->prices->contains($price)) {
  50.             $this->prices[] = $price;
  51.             $price->setTypeReservation($this);
  52.         }
  53.         return $this;
  54.     }
  55.     public function removePrice(Price $price): self
  56.     {
  57.         if ($this->prices->removeElement($price)) {
  58.             // set the owning side to null (unless already changed)
  59.             if ($price->getTypeReservation() === $this) {
  60.                 $price->setTypeReservation(null);
  61.             }
  62.         }
  63.         return $this;
  64.     }
  65. }