src/Entity/Coupon.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CouponRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8. * @ORM\Entity(repositoryClass=CouponRepository::class)
  9. */
  10. class Coupon
  11. {
  12. /**
  13. * @ORM\Id
  14. * @ORM\GeneratedValue
  15. * @ORM\Column(type="integer")
  16. */
  17. private $id;
  18. /**
  19. * @ORM\Column(type="string", length=255)
  20. */
  21. private $content;
  22. /**
  23. * @ORM\Column(type="string", length=255, nullable=true)
  24. */
  25. private $stripeId;
  26. /**
  27. * @ORM\OneToMany(targetEntity=PromoCode::class, mappedBy="coupon")
  28. */
  29. private $promoCodes;
  30. /**
  31. * @ORM\Column(type="float", nullable=true)
  32. */
  33. private $percentOff;
  34. public function __construct()
  35. {
  36. $this->promoCodes = new ArrayCollection();
  37. }
  38. public function getId(): ?int
  39. {
  40. return $this->id;
  41. }
  42. public function getContent(): ?string
  43. {
  44. return $this->content;
  45. }
  46. public function setContent(string $content): self
  47. {
  48. $this->content = $content;
  49. return $this;
  50. }
  51. public function getStripeId(): ?string
  52. {
  53. return $this->stripeId;
  54. }
  55. public function setStripeId(string $stripeId): self
  56. {
  57. $this->stripeId = $stripeId;
  58. return $this;
  59. }
  60. /**
  61. * @return Collection<int, PromoCode>
  62. */
  63. public function getPromoCodes(): Collection
  64. {
  65. return $this->promoCodes;
  66. }
  67. public function addPromoCode(PromoCode $promoCode): self
  68. {
  69. if (!$this->promoCodes->contains($promoCode)) {
  70. $this->promoCodes[] = $promoCode;
  71. $promoCode->setCoupon($this);
  72. }
  73. return $this;
  74. }
  75. public function removePromoCode(PromoCode $promoCode): self
  76. {
  77. if ($this->promoCodes->removeElement($promoCode)) {
  78. // set the owning side to null (unless already changed)
  79. if ($promoCode->getCoupon() === $this) {
  80. $promoCode->setCoupon(null);
  81. }
  82. }
  83. return $this;
  84. }
  85. public function __toString()
  86. {
  87. return $this->content;
  88. }
  89. public function getPercentOff(): ?int
  90. {
  91. return $this->percentOff;
  92. }
  93. public function setPercentOff(?int $percentOff): self
  94. {
  95. $this->percentOff = $percentOff;
  96. return $this;
  97. }
  98. }