src/Entity/PromoCodeUsage.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PromoCodeUsageRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6. * @ORM\Entity(repositoryClass=PromoCodeUsageRepository::class)
  7. */
  8. class PromoCodeUsage
  9. {
  10. /**
  11. * @ORM\Id
  12. * @ORM\GeneratedValue
  13. * @ORM\Column(type="integer")
  14. */
  15. private $id;
  16. /**
  17. * @ORM\Column(type="date_immutable")
  18. */
  19. private $fechaDeUso;
  20. /**
  21. * @ORM\ManyToOne(targetEntity=PromoCode::class, inversedBy="promoCodeUsages", cascade={"persist"})
  22. */
  23. private $promoCode;
  24. /**
  25. * @ORM\Column(type="integer", nullable=true)
  26. */
  27. private $platformFee;
  28. /**
  29. * @ORM\Column(type="integer", nullable=true)
  30. */
  31. private $commission;
  32. /**
  33. * @ORM\Column(type="boolean", nullable=true)
  34. */
  35. private $isPayed;
  36. /**
  37. * @ORM\Column(type="boolean", nullable=true)
  38. */
  39. private $inPayout;
  40. /**
  41. * @ORM\ManyToOne(targetEntity=Payout::class, inversedBy="promoCodeUsages")
  42. */
  43. private $payout;
  44. /**
  45. * @ORM\Column(type="string", length=255, nullable=true)
  46. */
  47. private $currentPlace;
  48. /**
  49. * @ORM\OneToOne(targetEntity=Subscription::class, inversedBy="promoCodeUsage", cascade={"persist", "remove"})
  50. */
  51. private $subscription;
  52. public function __construct()
  53. {
  54. if(!$this->fechaDeUso) $this->setFechaDeUso(new \DateTimeImmutable());
  55. }
  56. public function getId(): ?int
  57. {
  58. return $this->id;
  59. }
  60. public function getFechaDeUso(): ?\DateTimeImmutable
  61. {
  62. return $this->fechaDeUso;
  63. }
  64. public function setFechaDeUso(\DateTimeImmutable $fechaDeUso): self
  65. {
  66. $this->fechaDeUso = $fechaDeUso;
  67. return $this;
  68. }
  69. public function getPromoCode(): ?PromoCode
  70. {
  71. return $this->promoCode;
  72. }
  73. public function setPromoCode(?PromoCode $promoCode): self
  74. {
  75. $this->promoCode = $promoCode;
  76. return $this;
  77. }
  78. public function getPromoCodeUser()
  79. {
  80. return $this->getPromoCode()->getUser();
  81. }
  82. public function getPlatformFee(): ?int
  83. {
  84. return $this->platformFee;
  85. }
  86. public function setPlatformFee(?int $platformFee): self
  87. {
  88. $this->platformFee = $platformFee;
  89. return $this;
  90. }
  91. public function getCommission(): ?int
  92. {
  93. return $this->commission;
  94. }
  95. public function setCommission(?int $commission): self
  96. {
  97. $this->commission = $commission;
  98. return $this;
  99. }
  100. public function getIsPayed(): ?bool
  101. {
  102. return $this->isPayed;
  103. }
  104. public function setIsPayed(?bool $isPayed): self
  105. {
  106. $this->isPayed = $isPayed;
  107. return $this;
  108. }
  109. public function isInPayout(): ?bool
  110. {
  111. return $this->inPayout;
  112. }
  113. public function setInPayout(?bool $inPayout): self
  114. {
  115. $this->inPayout = $inPayout;
  116. return $this;
  117. }
  118. public function getPayout(): ?Payout
  119. {
  120. return $this->payout;
  121. }
  122. public function setPayout(?Payout $payout): self
  123. {
  124. $this->payout = $payout;
  125. return $this;
  126. }
  127. public function getCurrentPlace(): ?string
  128. {
  129. return $this->currentPlace;
  130. }
  131. public function setCurrentPlace(?string $currentPlace): self
  132. {
  133. $this->currentPlace = $currentPlace;
  134. return $this;
  135. }
  136. public function __toString()
  137. {
  138. return $this->getFechaDeUso()->format('d M Y');
  139. }
  140. public function getSubscription(): ?Subscription
  141. {
  142. return $this->subscription;
  143. }
  144. public function setSubscription(?Subscription $subscription): self
  145. {
  146. $this->subscription = $subscription;
  147. return $this;
  148. }
  149. }