src/Entity/Plan.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7. * @ORM\Entity(repositoryClass="App\Repository\PlanRepository")
  8. */
  9. class Plan
  10. {
  11. /**
  12. * @ORM\Id()
  13. * @ORM\GeneratedValue()
  14. * @ORM\Column(type="integer")
  15. */
  16. private $id;
  17. /**
  18. * @ORM\Column(type="string", length=255)
  19. */
  20. private $stripeId;
  21. /**
  22. * @ORM\Column(type="string", length=255)
  23. */
  24. private $frequency;
  25. /**
  26. * @ORM\Column(type="decimal", precision=25, scale=15)
  27. */
  28. private $price;
  29. /**
  30. * @ORM\Column(type="string", length=255)
  31. */
  32. private $name;
  33. /**
  34. * @ORM\ManyToOne(targetEntity="App\Entity\Category", inversedBy="plans")
  35. * @ORM\JoinColumn(nullable=false)
  36. */
  37. private $category;
  38. /**
  39. * @ORM\OneToMany(targetEntity="App\Entity\SubscriptionOrder", mappedBy="plan")
  40. */
  41. private $subscriptionOrders;
  42. /**
  43. * @ORM\Column(type="integer", nullable=true)
  44. */
  45. private $durationPerWeek;
  46. /**
  47. * @ORM\OneToMany(targetEntity="App\Entity\PlanUpdateLog", mappedBy="changeFrom")
  48. */
  49. private $planUpdateLogsFrom;
  50. /**
  51. * @ORM\OneToMany(targetEntity="App\Entity\PlanUpdateLog", mappedBy="changeTo")
  52. */
  53. private $planUpdateLogsTo;
  54. /**
  55. * @ORM\Column(type="string", length=50)
  56. */
  57. private $frequencyEn;
  58. /**
  59. * @ORM\Column(type="boolean", nullable=true)
  60. */
  61. private $isOld;
  62. public function __construct()
  63. {
  64. $this->subscriptionOrders = new ArrayCollection();
  65. $this->planUpdateLogsFrom = new ArrayCollection();
  66. $this->planUpdateLogsTo = new ArrayCollection();
  67. }
  68. public function getId(): ?int
  69. {
  70. return $this->id;
  71. }
  72. public function getStripeId(): ?string
  73. {
  74. return $this->stripeId;
  75. }
  76. public function setStripeId(string $stripeId): self
  77. {
  78. $this->stripeId = $stripeId;
  79. return $this;
  80. }
  81. public function getFrequency(): ?string
  82. {
  83. return $this->frequency;
  84. }
  85. public function setFrequency(string $frequency): self
  86. {
  87. $this->frequency = $frequency;
  88. return $this;
  89. }
  90. public function getPrice(): ?float
  91. {
  92. return $this->price;
  93. }
  94. public function setPrice(float $price): self
  95. {
  96. $this->price = round($price, 2);
  97. return $this;
  98. }
  99. public function getName(): ?string
  100. {
  101. return $this->name;
  102. }
  103. public function setName(string $name): self
  104. {
  105. $this->name = $name;
  106. return $this;
  107. }
  108. public function getCategory(): ?Category
  109. {
  110. return $this->category;
  111. }
  112. public function setCategory(?Category $category): self
  113. {
  114. $this->category = $category;
  115. return $this;
  116. }
  117. /**
  118. * @return Collection|SubscriptionOrder[]
  119. */
  120. public function getSubscriptionOrders(): Collection
  121. {
  122. return $this->subscriptionOrders;
  123. }
  124. public function addSubscriptionOrder(SubscriptionOrder $subscriptionOrder): self
  125. {
  126. if (!$this->subscriptionOrders->contains($subscriptionOrder)) {
  127. $this->subscriptionOrders[] = $subscriptionOrder;
  128. $subscriptionOrder->setPlan($this);
  129. }
  130. return $this;
  131. }
  132. public function removeSubscriptionOrder(SubscriptionOrder $subscriptionOrder): self
  133. {
  134. if ($this->subscriptionOrders->contains($subscriptionOrder)) {
  135. $this->subscriptionOrders->removeElement($subscriptionOrder);
  136. // set the owning side to null (unless already changed)
  137. if ($subscriptionOrder->getPlan() === $this) {
  138. $subscriptionOrder->setPlan(null);
  139. }
  140. }
  141. return $this;
  142. }
  143. public function getDurationPerWeek(): ?int
  144. {
  145. return $this->durationPerWeek;
  146. }
  147. public function setDurationPerWeek(int $durationPerWeek): self
  148. {
  149. $this->durationPerWeek = $durationPerWeek;
  150. return $this;
  151. }
  152. /**
  153. * @return Collection|PlanUpdateLog[]
  154. */
  155. public function getPlanUpdateLogsFrom(): Collection
  156. {
  157. return $this->planUpdateLogsFrom;
  158. }
  159. public function addPlanUpdateLogFrom(PlanUpdateLog $planUpdateLogFrom): self
  160. {
  161. if (!$this->planUpdateLogsFrom->contains($planUpdateLogFrom)) {
  162. $this->planUpdateLogsFrom[] = $planUpdateLogFrom;
  163. $planUpdateLogFrom->setChangeFrom($this);
  164. }
  165. return $this;
  166. }
  167. public function removePlanUpdateLogFrom(PlanUpdateLog $planUpdateLogFrom): self
  168. {
  169. if ($this->planUpdateLogsFrom->contains($planUpdateLogFrom)) {
  170. $this->planUpdateLogsFrom->removeElement($planUpdateLogFrom);
  171. // set the owning side to null (unless already changed)
  172. if ($planUpdateLogFrom->getChangeFrom() === $this) {
  173. $planUpdateLogFrom->setChangeFrom(null);
  174. }
  175. }
  176. return $this;
  177. }
  178. public function getPlanUpdateLogsTo()
  179. {
  180. return $this->planUpdateLogsTo;
  181. }
  182. public function addPlanUpdateLogTo(PlanUpdateLog $planUpdateLogTo): self
  183. {
  184. if (!$this->planUpdateLogsTo->contains($planUpdateLogTo)) {
  185. $this->planUpdateLogsTo[] = $planUpdateLogTo;
  186. $planUpdateLogTo->setChangeFrom($this);
  187. }
  188. return $this;
  189. }
  190. public function removePlanUpdateLogTo(PlanUpdateLog $planUpdateLogTo): self
  191. {
  192. if ($this->planUpdateLogsTo->contains($planUpdateLogTo)) {
  193. $this->planUpdateLogsTo->removeElement($planUpdateLogTo);
  194. // set the owning side to null (unless already changed)
  195. if ($planUpdateLogTo->getChangeFrom() === $this) {
  196. $planUpdateLogTo->setChangeFrom(null);
  197. }
  198. }
  199. return $this;
  200. }
  201. public function __toString()
  202. {
  203. return $this->getFrequency();
  204. }
  205. public function getFrequencyEn(): ?string
  206. {
  207. return $this->frequencyEn;
  208. }
  209. public function setFrequencyEn(?string $frequencyEn): self
  210. {
  211. $this->frequencyEn = $frequencyEn;
  212. return $this;
  213. }
  214. public function getIsOld(): ?bool
  215. {
  216. return $this->isOld;
  217. }
  218. public function setIsOld(?bool $isOld): self
  219. {
  220. $this->isOld = $isOld;
  221. return $this;
  222. }
  223. }