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
  42. *
  43. * @ORM\ManyToOne(targetEntity="ProductAttribute", inversedBy="minimumOrderQuantitys")
  44. *
  45. * @ORM\JoinColumn(name="id_product_attribute", referencedColumnName="id_product_attribute")
  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. /**
  92. * @return ProductAttribute
  93. */
  94. public function getProductAttribute(): ProductAttribute
  95. {
  96. return $this->productAttribute;
  97. }
  98. /**
  99. * @param ProductAttribute $productAttribute
  100. *
  101. * @return MinimumOrderQuantity
  102. */
  103. public function setProductAttribute(ProductAttribute $productAttribute): MinimumOrderQuantity
  104. {
  105. $this->productAttribute = $productAttribute;
  106. return $this;
  107. }
  108. /**
  109. * @return int
  110. */
  111. public function getQuantity(): int
  112. {
  113. return $this->quantity;
  114. }
  115. /**
  116. * @param int $quantity
  117. *
  118. * @return MinimumOrderQuantity
  119. */
  120. public function setQuantity(int $quantity): MinimumOrderQuantity
  121. {
  122. $this->quantity = $quantity;
  123. return $this;
  124. }
  125. /**
  126. * @return float
  127. */
  128. public function getPrice(): float
  129. {
  130. return $this->price;
  131. }
  132. /**
  133. * @param float $price
  134. *
  135. * @return MinimumOrderQuantity
  136. */
  137. public function setPrice(float $price): MinimumOrderQuantity
  138. {
  139. $this->price = $price;
  140. return $this;
  141. }
  142. /**
  143. * @return \DateTime
  144. */
  145. public function getDateAdd(): \DateTime
  146. {
  147. return $this->dateAdd;
  148. }
  149. /**
  150. * @param \DateTime $dateAdd
  151. *
  152. * @return MinimumOrderQuantity
  153. */
  154. public function setDateAdd(\DateTime $dateAdd): MinimumOrderQuantity
  155. {
  156. $this->dateAdd = $dateAdd;
  157. return $this;
  158. }
  159. public function __toString()
  160. {
  161. return "Q: {$this->getQuantity()}, P: {$this->getPrice()},";
  162. }
  163. }