<?phpnamespace App\Entity;use ApiPlatform\Core\Annotation\ApiResource;use App\Repository\SubscriptionRepository;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=SubscriptionRepository::class) */class Subscription{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") * @Groups({"subscription:read"}) */ private $id; /** * @ORM\Column(type="string", length=255) * @Groups({"subscription:read"}) */ private $name; /** * @ORM\Column(type="integer") * @Groups({"subscription:read"}) */ private $duration; /** * @ORM\Column(type="integer") * @Groups({"subscription:read"}) */ private $credits; /** * @ORM\Column(type="float") * @Groups({"subscription:read"}) */ private $priceHt; /** * @ORM\OneToMany(targetEntity=Order::class, mappedBy="subscription") * @Groups({"subscription:read"}) */ private $orders; public function __construct() { $this->orders = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getName(): ?string { return $this->name; } public function setName(string $name): self { $this->name = $name; return $this; } public function getDuration(): ?int { return $this->duration; } public function setDuration(int $duration): self { $this->duration = $duration; return $this; } public function getCredits(): ?int { return $this->credits; } public function setCredits(int $credits): self { $this->credits = $credits; return $this; } public function getPriceHt(): ?float { return $this->priceHt; } public function setPriceHt(float $priceHt): self { $this->priceHt = $priceHt; return $this; } /** * @return Collection|Order[] */ public function getOrders(): Collection { return $this->orders; } public function addOrder(Order $order): self { if (!$this->orders->contains($order)) { $this->orders[] = $order; $order->setSubscription($this); } return $this; } public function removeOrder(Order $order): self { if ($this->orders->removeElement($order)) { // set the owning side to null (unless already changed) if ($order->getSubscription() === $this) { $order->setSubscription(null); } } return $this; }}