src/Entity/AbonnementItem.php line 12
<?php
namespace App\Entity;
use App\Repository\AbonnementItemRepository;
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: AbonnementItemRepository::class)]
class AbonnementItem
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['read:abonnement:collection'])]
private ?int $id = null;
#[ORM\Column(length: 255)]
#[Groups(['read:abonnement:collection'])]
private ?string $label = null;
#[ORM\ManyToMany(targetEntity: Abonnement::class, mappedBy: 'items')]
private Collection $abonnements;
public function __construct()
{
$this->abonnements = 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;
}
/**
* @return Collection<int, Abonnement>
*/
public function getAbonnements(): Collection
{
return $this->abonnements;
}
public function addAbonnement(Abonnement $abonnement): self
{
if (!$this->abonnements->contains($abonnement)) {
$this->abonnements->add($abonnement);
$abonnement->addItem($this);
}
return $this;
}
public function removeAbonnement(Abonnement $abonnement): self
{
if ($this->abonnements->removeElement($abonnement)) {
$abonnement->removeItem($this);
}
return $this;
}
}