<?phpnamespace App\Entity\Catalog;use ApiPlatform\Core\Annotation\ApiResource;use App\Repository\Catalog\GiftLevelRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Serializer\Annotation\Groups;use Symfony\Component\Serializer\Annotation\SerializedName;/** * @ORM\Entity(repositoryClass=GiftLevelRepository::class) * @ApiResource( * collectionOperations={"get"}, * itemOperations={"get"}, * ) */class GiftLevel{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") * @Groups({ * "Gift:output", * }) */ private $id; /** * @ORM\Column(type="string", length=255) * @SerializedName("label") * @Groups({ * "Gift:output", * }) */ private $label; /** * @ORM\Column(type="text", nullable=true) * @SerializedName("description") * @Groups({ * "Gift:output", * }) */ private $description; /** * @ORM\OneToMany(targetEntity=Gift::class, mappedBy="level") */ private $gifts; public function __construct() { $this->gifts = new ArrayCollection(); } /** * @return mixed */ public function getId() { return $this->id; } public function getLabel(): ?string { return $this->label; } public function setLabel(string $label): self { $this->label = $label; return $this; } public function getDescription(): ?string { return $this->description; } public function setDescription(?string $description): self { $this->description = $description; return $this; } /** * @return Collection|Gift[] */ public function getGifts(): Collection { return $this->gifts; } public function addGift(Gift $gift): self { if (!$this->gifts->contains($gift)) { $this->gifts[] = $gift; $gift->setLevel($this); } return $this; } public function removeGift(Gift $gift): self { if ($this->gifts->removeElement($gift)) { // set the owning side to null (unless already changed) if ($gift->getLevel() === $this) { $gift->setLevel(null); } } return $this; } public function __toString() { return $this->label; }}