src/Entity/Product.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ProductRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8. * @ORM\Entity(repositoryClass=ProductRepository::class)
  9. */
  10. class Product
  11. {
  12. /**
  13. * @ORM\Id()
  14. * @ORM\GeneratedValue()
  15. * @ORM\Column(type="integer")
  16. */
  17. private $id;
  18. /**
  19. * @ORM\ManyToOne(targetEntity=Programa::class, inversedBy="products", cascade={"persist"})
  20. */
  21. private $programa;
  22. /**
  23. * @ORM\ManyToOne(targetEntity=Rate::class, inversedBy="products", cascade={"persist"})
  24. */
  25. private $rate;
  26. /**
  27. * @ORM\Column(type="boolean", options={"default"=1}, nullable=true)
  28. */
  29. private $publico;
  30. /**
  31. * @ORM\Column(type="boolean", nullable=true)
  32. */
  33. private $isPrimary;
  34. /**
  35. * @ORM\Column(type="boolean", nullable=true)
  36. */
  37. private $isPublico;
  38. /**
  39. * @ORM\Column(type="boolean", nullable=true)
  40. */
  41. private $isActivo;
  42. /**
  43. * @ORM\Column(type="string", length=255, nullable=true)
  44. */
  45. private $stripeId;
  46. /**
  47. * @ORM\Column(type="string", length=255, nullable=true)
  48. */
  49. private $stripePriceId;
  50. /**
  51. * @ORM\Column(type="integer", nullable=true)
  52. */
  53. private $platformFee;
  54. /**
  55. * @ORM\Column(type="boolean", nullable=true)
  56. */
  57. private $acceptsPromoCode;
  58. /**
  59. * @ORM\Column(type="string", length=255, nullable=true)
  60. */
  61. private $abrev;
  62. public function __construct()
  63. {
  64. $this->ordenItems = new ArrayCollection();
  65. }
  66. public function getId(): ?int
  67. {
  68. return $this->id;
  69. }
  70. public function getPrograma(): ?Programa
  71. {
  72. return $this->programa;
  73. }
  74. public function setPrograma(?Programa $programa): self
  75. {
  76. $this->programa = $programa;
  77. return $this;
  78. }
  79. public function getRate(): ?Rate
  80. {
  81. return $this->rate;
  82. }
  83. public function setRate(?Rate $rate): self
  84. {
  85. $this->rate = $rate;
  86. return $this;
  87. }
  88. public function getRatePrecio()
  89. {
  90. // dd($this->getRate());
  91. if($this->getRate()){
  92. return $this->getRate()->getPrice();
  93. }
  94. return 0;
  95. }
  96. public function getPublico(): ?bool
  97. {
  98. return $this->publico;
  99. }
  100. public function setPublico(bool $publico): self
  101. {
  102. $this->publico = $publico;
  103. return $this;
  104. }
  105. public function getProductName(): string
  106. {
  107. return $this->rate . ' ' . $this->programa;
  108. }
  109. public function getProgramaType()
  110. {
  111. return $this->getPrograma()->getProgramaType();
  112. }
  113. public function getProductPrice()
  114. {
  115. return number_format($this->getRate()->getPrice(), 2);
  116. }
  117. public function __toString()
  118. {
  119. return $this->rate . ' ' . $this->programa;
  120. }
  121. public function getIsPrimary(): ?bool
  122. {
  123. return $this->isPrimary;
  124. }
  125. public function setIsPrimary(bool $isPrimary): self
  126. {
  127. $this->isPrimary = $isPrimary;
  128. return $this;
  129. }
  130. public function getIsPublico(): ?bool
  131. {
  132. return $this->isPublico;
  133. }
  134. public function setIsPublico(?bool $isPublico): self
  135. {
  136. $this->isPublico = $isPublico;
  137. return $this;
  138. }
  139. public function isIsActivo(): ?bool
  140. {
  141. return $this->isActivo;
  142. }
  143. public function setIsActivo(?bool $isActivo): self
  144. {
  145. $this->isActivo = $isActivo;
  146. return $this;
  147. }
  148. public function getStripeId(): ?string
  149. {
  150. return $this->stripeId;
  151. }
  152. public function setStripeId(?string $stripeId): self
  153. {
  154. $this->stripeId = $stripeId;
  155. return $this;
  156. }
  157. public function getStripePriceId(): ?string
  158. {
  159. return $this->stripePriceId;
  160. }
  161. public function setStripePriceId(?string $stripePriceId): self
  162. {
  163. $this->stripePriceId = $stripePriceId;
  164. return $this;
  165. }
  166. public function getPlatformFee(): ?int
  167. {
  168. return $this->platformFee;
  169. }
  170. public function setPlatformFee(?int $platformFee): self
  171. {
  172. $this->platformFee = $platformFee;
  173. return $this;
  174. }
  175. public function getAcceptsPromoCode(): ?bool
  176. {
  177. return $this->acceptsPromoCode;
  178. }
  179. public function setAcceptsPromoCode(bool $acceptsPromoCode): self
  180. {
  181. $this->acceptsPromoCode = $acceptsPromoCode;
  182. return $this;
  183. }
  184. public function getAbrev(): ?string
  185. {
  186. return $this->abrev;
  187. }
  188. public function setAbrev(?string $abrev): self
  189. {
  190. $this->abrev = $abrev;
  191. return $this;
  192. }
  193. }