<?php
namespace App\Entity;
use App\Doctrine\Types\PlanDurationType;
use App\Entity\SuperClass\BaseEntity;
use App\Repository\OrderItemRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=OrderItemRepository::class)
*/
class OrderItem extends BaseEntity
{
/**
* @ORM\ManyToOne(targetEntity=Product::class, inversedBy="orderItems")
*/
private $products;
/**
* @ORM\Column(type="integer")
*/
private $quantity;
/**
* @ORM\ManyToOne(targetEntity=Order::class, inversedBy="orderItems")
*/
private $orderRef;
/**
* @ORM\ManyToOne(targetEntity=Installment::class, inversedBy="orderItems")
*/
private $payment_option;
/**
* @ORM\Column(type="boolean")
*/
private $is_subscription;
public function getProducts(): ?Product
{
return $this->products;
}
public function setProducts(?Product $products): self
{
$this->products = $products;
return $this;
}
public function getQuantity(): ?int
{
return $this->quantity;
}
public function setQuantity(int $quantity): self
{
$this->quantity = $quantity;
return $this;
}
public function getOrderRef(): ?Order
{
return $this->orderRef;
}
public function setOrderRef(?Order $orderRef): self
{
$this->orderRef = $orderRef;
return $this;
}
public function getPaymentOption(): ?Installment
{
return $this->payment_option;
}
public function setPaymentOption(?Installment $payment_option): self
{
$this->payment_option = $payment_option;
$this->setIsSubscription();
return $this;
}
public function getIsSubscription(): ?bool
{
return $this->is_subscription;
}
public function setIsSubscription(): self
{
$this->is_subscription = $this->getPaymentOption()->getDuration() != PlanDurationType::PAY_IN_FULL;
return $this;
}
}