src/Entity/AbonnementItem.php line 12

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AbonnementItemRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. #[ORM\Entity(repositoryClassAbonnementItemRepository::class)]
  9. class AbonnementItem
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     #[Groups(['read:abonnement:collection'])]
  15.     private ?int $id null;
  16.     #[ORM\Column(length255)]
  17.     #[Groups(['read:abonnement:collection'])]
  18.     private ?string $label null;
  19.     #[ORM\ManyToMany(targetEntityAbonnement::class, mappedBy'items')]
  20.     private Collection $abonnements;
  21.     public function __construct()
  22.     {
  23.         $this->abonnements = new ArrayCollection();
  24.     }
  25.     public function getId(): ?int
  26.     {
  27.         return $this->id;
  28.     }
  29.     public function getLabel(): ?string
  30.     {
  31.         return $this->label;
  32.     }
  33.     public function setLabel(string $label): self
  34.     {
  35.         $this->label $label;
  36.         return $this;
  37.     }
  38.     /**
  39.      * @return Collection<int, Abonnement>
  40.      */
  41.     public function getAbonnements(): Collection
  42.     {
  43.         return $this->abonnements;
  44.     }
  45.     public function addAbonnement(Abonnement $abonnement): self
  46.     {
  47.         if (!$this->abonnements->contains($abonnement)) {
  48.             $this->abonnements->add($abonnement);
  49.             $abonnement->addItem($this);
  50.         }
  51.         return $this;
  52.     }
  53.     public function removeAbonnement(Abonnement $abonnement): self
  54.     {
  55.         if ($this->abonnements->removeElement($abonnement)) {
  56.             $abonnement->removeItem($this);
  57.         }
  58.         return $this;
  59.     }
  60. }