src/Entity/TypePitch.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\TypePitchRepository;
  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(repositoryClassTypePitchRepository::class)]
  10. #[ApiResource()]
  11. class TypePitch
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[Groups(['pitch:read','price:read'])]
  16.     #[ORM\Column(type'integer')]
  17.     private $id;
  18.     #[Groups(['pitch:read','price:read'])]
  19.     #[ORM\Column(type'string'length100)]
  20.     private $label;
  21.     #[ORM\OneToMany(mappedBy'typePitch'targetEntityPitch::class)]
  22.     private $pitches;
  23.     #[Groups(['pitch:read','price:read'])]
  24.     #[ORM\Column(type'string'length20,unique:true)]
  25.     private $code;
  26.     #[ORM\OneToMany(mappedBy'typePitch'targetEntityPrice::class)]
  27.     private $prices;
  28.     public function __construct()
  29.     {
  30.         $this->pitches = new ArrayCollection();
  31.         $this->prices = 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.     /**
  47.      * @return Collection<int, Pitch>
  48.      */
  49.     public function getPitches(): Collection
  50.     {
  51.         return $this->pitches;
  52.     }
  53.     public function addPitch(Pitch $pitch): self
  54.     {
  55.         if (!$this->pitches->contains($pitch)) {
  56.             $this->pitches[] = $pitch;
  57.             $pitch->setTypePitch($this);
  58.         }
  59.         return $this;
  60.     }
  61.     public function removePitch(Pitch $pitch): self
  62.     {
  63.         if ($this->pitches->removeElement($pitch)) {
  64.             // set the owning side to null (unless already changed)
  65.             if ($pitch->getTypePitch() === $this) {
  66.                 $pitch->setTypePitch(null);
  67.             }
  68.         }
  69.         return $this;
  70.     }
  71.     public function getCode(): ?string
  72.     {
  73.         return $this->code;
  74.     }
  75.     public function setCode(string $code): self
  76.     {
  77.         $this->code $code;
  78.         return $this;
  79.     }
  80.     /**
  81.      * @return Collection<int, Price>
  82.      */
  83.     public function getPrices(): Collection
  84.     {
  85.         return $this->prices;
  86.     }
  87.     public function addPrice(Price $price): self
  88.     {
  89.         if (!$this->prices->contains($price)) {
  90.             $this->prices[] = $price;
  91.             $price->setTypePitch($this);
  92.         }
  93.         return $this;
  94.     }
  95.     public function removePrice(Price $price): self
  96.     {
  97.         if ($this->prices->removeElement($price)) {
  98.             // set the owning side to null (unless already changed)
  99.             if ($price->getTypePitch() === $this) {
  100.                 $price->setTypePitch(null);
  101.             }
  102.         }
  103.         return $this;
  104.     }
  105. }