src/Entity/System/MinimumOrderQuantity.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\System;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5. * MinimumOrderQuantity
  6. *
  7. * @ORM\Table(name="ps_minimum_order_quantity")
  8. *
  9. * @ORM\Entity(repositoryClass="App\Repository\System\MinimumOrderQuantityRepository")
  10. */
  11. class MinimumOrderQuantity
  12. {
  13. public const WITHOUT_QUANTITY_DISCOUNT = 0;
  14. public const FIRST_STEP_QUANTITY_DISCOUNT = 1;
  15. public const SECOND_STEP_QUANTITY_DISCOUNT = 2;
  16. public const THIRD_STEP_QUANTITY_DISCOUNT = 2;
  17. public const STEPS_QUANTITY_DISCOUNT = [
  18. self::FIRST_STEP_QUANTITY_DISCOUNT,
  19. self::SECOND_STEP_QUANTITY_DISCOUNT,
  20. self::THIRD_STEP_QUANTITY_DISCOUNT,
  21. ];
  22. /**
  23. * @var int
  24. *
  25. * @ORM\Column(name="id_order_minimum_quantity", type="integer", options={"unsigned":true})
  26. *
  27. * @ORM\Id
  28. *
  29. * @ORM\GeneratedValue(strategy="AUTO")
  30. */
  31. private $id;
  32. /**
  33. * @var Product
  34. *
  35. * @ORM\ManyToOne(targetEntity="Product", inversedBy="minimumOrderQuantitys")
  36. *
  37. * @ORM\JoinColumn(name="id_product", referencedColumnName="id_product", nullable=false)
  38. */
  39. private $product;
  40. /**
  41. * @var ProductAttribute|null
  42. *
  43. * @ORM\ManyToOne(targetEntity="ProductAttribute", inversedBy="minimumOrderQuantitys")
  44. *
  45. * @ORM\JoinColumn(name="id_product_attribute", referencedColumnName="id_product_attribute", nullable=true)
  46. */
  47. private $productAttribute;
  48. /**
  49. * @var int
  50. *
  51. * @ORM\Column(name="quantity", type="integer", options={"default" : 0})
  52. */
  53. private $quantity;
  54. /**
  55. * @var float
  56. *
  57. * @ORM\Column(name="price", type="float", options={"default" : 0})
  58. */
  59. private $price;
  60. /**
  61. * @var \DateTime
  62. *
  63. * @ORM\Column(name="date_add", type="datetime")
  64. */
  65. private $dateAdd;
  66. public function __construct()
  67. {
  68. $this->dateAdd = new \DateTime();
  69. }
  70. /**
  71. * @return int
  72. */
  73. public function getId(): int
  74. {
  75. return $this->id;
  76. }
  77. public function getProduct(): Product
  78. {
  79. return $this->product;
  80. }
  81. /**
  82. * @param Product $product
  83. *
  84. * @return MinimumOrderQuantity
  85. */
  86. public function setProduct(Product $product): MinimumOrderQuantity
  87. {
  88. $this->product = $product;
  89. return $this;
  90. }
  91. public function getProductAttribute(): ?ProductAttribute
  92. {
  93. return $this->productAttribute;
  94. }
  95. public function setProductAttribute(?ProductAttribute $productAttribute = null): MinimumOrderQuantity
  96. {
  97. $this->productAttribute = $productAttribute;
  98. return $this;
  99. }
  100. /**
  101. * @return int
  102. */
  103. public function getQuantity(): int
  104. {
  105. return $this->quantity;
  106. }
  107. /**
  108. * @param int $quantity
  109. *
  110. * @return MinimumOrderQuantity
  111. */
  112. public function setQuantity(int $quantity): MinimumOrderQuantity
  113. {
  114. $this->quantity = $quantity;
  115. return $this;
  116. }
  117. /**
  118. * @return float
  119. */
  120. public function getPrice(): float
  121. {
  122. return $this->price;
  123. }
  124. /**
  125. * @param float $price
  126. *
  127. * @return MinimumOrderQuantity
  128. */
  129. public function setPrice(float $price): MinimumOrderQuantity
  130. {
  131. $this->price = $price;
  132. return $this;
  133. }
  134. /**
  135. * @return \DateTime
  136. */
  137. public function getDateAdd(): \DateTime
  138. {
  139. return $this->dateAdd;
  140. }
  141. /**
  142. * @param \DateTime $dateAdd
  143. *
  144. * @return MinimumOrderQuantity
  145. */
  146. public function setDateAdd(\DateTime $dateAdd): MinimumOrderQuantity
  147. {
  148. $this->dateAdd = $dateAdd;
  149. return $this;
  150. }
  151. public function __toString()
  152. {
  153. return "Q: {$this->getQuantity()}, P: {$this->getPrice()},";
  154. }
  155. }