src/Entity/OrderItem.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Doctrine\Types\PlanDurationType;
  4. use App\Entity\SuperClass\BaseEntity;
  5. use App\Repository\OrderItemRepository;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8. * @ORM\Entity(repositoryClass=OrderItemRepository::class)
  9. */
  10. class OrderItem extends BaseEntity
  11. {
  12. /**
  13. * @ORM\ManyToOne(targetEntity=Product::class, inversedBy="orderItems")
  14. */
  15. private $products;
  16. /**
  17. * @ORM\Column(type="integer")
  18. */
  19. private $quantity;
  20. /**
  21. * @ORM\ManyToOne(targetEntity=Order::class, inversedBy="orderItems")
  22. */
  23. private $orderRef;
  24. /**
  25. * @ORM\ManyToOne(targetEntity=Installment::class, inversedBy="orderItems")
  26. */
  27. private $payment_option;
  28. /**
  29. * @ORM\Column(type="boolean")
  30. */
  31. private $is_subscription;
  32. public function getProducts(): ?Product
  33. {
  34. return $this->products;
  35. }
  36. public function setProducts(?Product $products): self
  37. {
  38. $this->products = $products;
  39. return $this;
  40. }
  41. public function getQuantity(): ?int
  42. {
  43. return $this->quantity;
  44. }
  45. public function setQuantity(int $quantity): self
  46. {
  47. $this->quantity = $quantity;
  48. return $this;
  49. }
  50. public function getOrderRef(): ?Order
  51. {
  52. return $this->orderRef;
  53. }
  54. public function setOrderRef(?Order $orderRef): self
  55. {
  56. $this->orderRef = $orderRef;
  57. return $this;
  58. }
  59. public function getPaymentOption(): ?Installment
  60. {
  61. return $this->payment_option;
  62. }
  63. public function setPaymentOption(?Installment $payment_option): self
  64. {
  65. $this->payment_option = $payment_option;
  66. $this->setIsSubscription();
  67. return $this;
  68. }
  69. public function getIsSubscription(): ?bool
  70. {
  71. return $this->is_subscription;
  72. }
  73. public function setIsSubscription(): self
  74. {
  75. $this->is_subscription = $this->getPaymentOption()->getDuration() != PlanDurationType::PAY_IN_FULL;
  76. return $this;
  77. }
  78. }