src/Entity/Subscription.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\SubscriptionRepository;
  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. /**
  10.  * @ORM\Entity(repositoryClass=SubscriptionRepository::class)
  11.  */
  12. class Subscription
  13. {
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      * @Groups({"subscription:read"})
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\Column(type="string", length=255)
  23.      * @Groups({"subscription:read"})
  24.      */
  25.     private $name;
  26.     /**
  27.      * @ORM\Column(type="integer")
  28.      * @Groups({"subscription:read"})
  29.      */
  30.     private $duration;
  31.     /**
  32.      * @ORM\Column(type="integer")
  33.      * @Groups({"subscription:read"})
  34.      */
  35.     private $credits;
  36.     /**
  37.      * @ORM\Column(type="float")
  38.      * @Groups({"subscription:read"})
  39.      */
  40.     private $priceHt;
  41.     /**
  42.      * @ORM\OneToMany(targetEntity=Order::class, mappedBy="subscription")
  43.      * @Groups({"subscription:read"})
  44.      */
  45.     private $orders;
  46.     public function __construct()
  47.     {
  48.         $this->orders = new ArrayCollection();
  49.     }
  50.     public function getId(): ?int
  51.     {
  52.         return $this->id;
  53.     }
  54.     public function getName(): ?string
  55.     {
  56.         return $this->name;
  57.     }
  58.     public function setName(string $name): self
  59.     {
  60.         $this->name $name;
  61.         return $this;
  62.     }
  63.     public function getDuration(): ?int
  64.     {
  65.         return $this->duration;
  66.     }
  67.     public function setDuration(int $duration): self
  68.     {
  69.         $this->duration $duration;
  70.         return $this;
  71.     }
  72.     public function getCredits(): ?int
  73.     {
  74.         return $this->credits;
  75.     }
  76.     public function setCredits(int $credits): self
  77.     {
  78.         $this->credits $credits;
  79.         return $this;
  80.     }
  81.     public function getPriceHt(): ?float
  82.     {
  83.         return $this->priceHt;
  84.     }
  85.     public function setPriceHt(float $priceHt): self
  86.     {
  87.         $this->priceHt $priceHt;
  88.         return $this;
  89.     }
  90.     /**
  91.      * @return Collection|Order[]
  92.      */
  93.     public function getOrders(): Collection
  94.     {
  95.         return $this->orders;
  96.     }
  97.     public function addOrder(Order $order): self
  98.     {
  99.         if (!$this->orders->contains($order)) {
  100.             $this->orders[] = $order;
  101.             $order->setSubscription($this);
  102.         }
  103.         return $this;
  104.     }
  105.     public function removeOrder(Order $order): self
  106.     {
  107.         if ($this->orders->removeElement($order)) {
  108.             // set the owning side to null (unless already changed)
  109.             if ($order->getSubscription() === $this) {
  110.                 $order->setSubscription(null);
  111.             }
  112.         }
  113.         return $this;
  114.     }
  115. }