src/Entity/System/CodeDiscount.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity\System;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7. * Class CodeDiscount
  8. *
  9. * @ORM\Table(name="code_discount")
  10. *
  11. * @ORM\Entity(repositoryClass="App\Repository\System\CodeDiscountRepository")
  12. */
  13. class CodeDiscount
  14. {
  15. public const FREE_SUBSCRIPTION_CODE_PREFIX = 'FREE_SUBSCRIPTION';
  16. public const FREE_CONNECTOR_CODE_PREFIX = 'FREE_CONNECTOR';
  17. public const FREE_MIGRATION_CODE = 'MIGRATION';
  18. /**
  19. * @ORM\Id()
  20. *
  21. * @ORM\GeneratedValue()
  22. *
  23. * @ORM\Column(type="integer")
  24. */
  25. private int $id;
  26. /**
  27. * @ORM\Column (type="string", length=30, unique=true)
  28. */
  29. private string $code;
  30. /**
  31. * @ORM\Column (type="boolean")
  32. */
  33. private bool $active = false;
  34. /**
  35. * @ORM\ManyToOne(targetEntity="App\Entity\System\Customer")
  36. *
  37. * @ORM\JoinColumn(name="customer", referencedColumnName="id_customer")
  38. */
  39. private ?Customer $customer = null;
  40. /**
  41. * @ORM\ManyToOne(targetEntity="App\Entity\System\Employee")
  42. *
  43. * @ORM\JoinColumn(name="employee", referencedColumnName="id_employee", nullable=false)
  44. */
  45. private Employee $employee;
  46. /**
  47. * @ORM\Column(type="integer", nullable=true)
  48. */
  49. private ?int $redeemLimit = null;
  50. /**
  51. * @ORM\Column(type="integer", nullable=true)
  52. */
  53. private ?int $redeemLimitByCustomer = null;
  54. /**
  55. * @var float
  56. *
  57. * @ORM\Column(type="float", options={"default" : 0.000000})
  58. */
  59. private $discount;
  60. /**
  61. * @var \DateTime|null
  62. *
  63. * @ORM\Column(type="datetime", nullable=true)
  64. */
  65. private $dateExpiration;
  66. /**
  67. * @var \DateTime
  68. *
  69. * @ORM\Column(type="datetime")
  70. */
  71. private $dateStarting;
  72. /**
  73. * @var Collection<int, Order>&iterable<Order>
  74. *
  75. * @ORM\OneToMany(targetEntity="App\Entity\System\Order", mappedBy="codeDiscount")
  76. */
  77. private $orders;
  78. /**
  79. * @var Collection<int, CodeDiscountRule>&iterable<CodeDiscountRule>
  80. *
  81. * @ORM\ManyToMany(targetEntity="CodeDiscountRule", inversedBy="codeDiscounts")
  82. */
  83. private $codeDiscountRules;
  84. /**
  85. * @ORM\Column (type="string", nullable=true)
  86. */
  87. private ?string $comments;
  88. /**
  89. * @var \DateTime
  90. *
  91. * @ORM\Column(type="datetime")
  92. */
  93. private $dateAdd;
  94. /**
  95. * @var \DateTime
  96. *
  97. * @ORM\Column(type="datetime")
  98. */
  99. private $dateUpd;
  100. public function __construct()
  101. {
  102. $this->orders = new ArrayCollection();
  103. $this->codeDiscountRules = new ArrayCollection();
  104. $this->dateAdd = new \DateTime();
  105. $this->dateUpd = new \DateTime();
  106. }
  107. /**
  108. * @return mixed
  109. */
  110. public function getId()
  111. {
  112. return $this->id;
  113. }
  114. public function getCode(): string
  115. {
  116. return $this->code;
  117. }
  118. public function isActive(): bool
  119. {
  120. return $this->active;
  121. }
  122. public function getCustomer(): ?Customer
  123. {
  124. return $this->customer;
  125. }
  126. public function getDiscount(): float
  127. {
  128. return $this->discount;
  129. }
  130. public function getDateExpiration(): ?\DateTime
  131. {
  132. return $this->dateExpiration;
  133. }
  134. public function getDateStarting(): \DateTime
  135. {
  136. return $this->dateStarting;
  137. }
  138. /**
  139. * @return Collection<int, Order>&iterable<Order>
  140. */
  141. public function getOrders()
  142. {
  143. return $this->orders;
  144. }
  145. /**
  146. * @param Collection<int, Order>&iterable<Order> $orders
  147. */
  148. public function setOrders($orders): self
  149. {
  150. $this->orders = $orders;
  151. return $this;
  152. }
  153. public function setCode(string $code): CodeDiscount
  154. {
  155. $this->code = $code;
  156. return $this;
  157. }
  158. public function setActive(bool $active): CodeDiscount
  159. {
  160. $this->active = $active;
  161. return $this;
  162. }
  163. public function setCustomer(?Customer $customer): CodeDiscount
  164. {
  165. $this->customer = $customer;
  166. return $this;
  167. }
  168. public function setDiscount(float $discount): CodeDiscount
  169. {
  170. $this->discount = $discount;
  171. return $this;
  172. }
  173. public function setDateExpiration(?\DateTime $dateExpiration): CodeDiscount
  174. {
  175. $this->dateExpiration = $dateExpiration;
  176. return $this;
  177. }
  178. public function setDateStarting(\DateTime $dateStarting): CodeDiscount
  179. {
  180. $this->dateStarting = $dateStarting;
  181. return $this;
  182. }
  183. /**
  184. * @return Collection<int, CodeDiscountRule>&iterable<CodeDiscountRule>
  185. */
  186. public function getCodeDiscountRules()
  187. {
  188. return $this->codeDiscountRules;
  189. }
  190. public function hasCodeDiscountRule(int $codeDiscountRuleId): bool
  191. {
  192. foreach ($this->codeDiscountRules as $codeDiscountRule) {
  193. if ($codeDiscountRule->getId() === $codeDiscountRuleId) {
  194. return true;
  195. }
  196. }
  197. return false;
  198. }
  199. public function addCodeDiscountRule(CodeDiscountRule $codeDiscountRule): CodeDiscount
  200. {
  201. if (!$this->codeDiscountRules->contains($codeDiscountRule)) {
  202. $this->codeDiscountRules[] = $codeDiscountRule;
  203. }
  204. return $this;
  205. }
  206. /**
  207. * @param Collection<int, CodeDiscountRule>&iterable<CodeDiscountRule> $codeDiscountRules
  208. */
  209. public function setCodeDiscountRules($codeDiscountRules): CodeDiscount
  210. {
  211. $this->codeDiscountRules = $codeDiscountRules;
  212. return $this;
  213. }
  214. public function getRedeemLimit(): ?int
  215. {
  216. return $this->redeemLimit;
  217. }
  218. public function setRedeemLimit(?int $redeemLimit): CodeDiscount
  219. {
  220. $this->redeemLimit = $redeemLimit;
  221. return $this;
  222. }
  223. public function getRedeemLimitByCustomer(): ?int
  224. {
  225. return $this->redeemLimitByCustomer;
  226. }
  227. public function setRedeemLimitByCustomer(?int $redeemLimitByCustomer): CodeDiscount
  228. {
  229. $this->redeemLimitByCustomer = $redeemLimitByCustomer;
  230. return $this;
  231. }
  232. public function getEmployee(): Employee
  233. {
  234. return $this->employee;
  235. }
  236. public function setEmployee(Employee $employee): CodeDiscount
  237. {
  238. $this->employee = $employee;
  239. return $this;
  240. }
  241. public function getComments(): ?string
  242. {
  243. return $this->comments;
  244. }
  245. public function setComments(?string $comments): CodeDiscount
  246. {
  247. $this->comments = $comments;
  248. return $this;
  249. }
  250. public function getDateAdd(): \DateTime
  251. {
  252. return $this->dateAdd;
  253. }
  254. public function setDateAdd(\DateTime $dateAdd): CodeDiscount
  255. {
  256. $this->dateAdd = $dateAdd;
  257. return $this;
  258. }
  259. public function getDateUpd(): \DateTime
  260. {
  261. return $this->dateUpd;
  262. }
  263. public function setDateUpd(\DateTime $dateUpd): CodeDiscount
  264. {
  265. $this->dateUpd = $dateUpd;
  266. return $this;
  267. }
  268. }