<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\PlanRepository")
*/
class Plan
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $stripeId;
/**
* @ORM\Column(type="string", length=255)
*/
private $frequency;
/**
* @ORM\Column(type="decimal", precision=25, scale=15)
*/
private $price;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Category", inversedBy="plans")
* @ORM\JoinColumn(nullable=false)
*/
private $category;
/**
* @ORM\OneToMany(targetEntity="App\Entity\SubscriptionOrder", mappedBy="plan")
*/
private $subscriptionOrders;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $durationPerWeek;
/**
* @ORM\OneToMany(targetEntity="App\Entity\PlanUpdateLog", mappedBy="changeFrom")
*/
private $planUpdateLogsFrom;
/**
* @ORM\OneToMany(targetEntity="App\Entity\PlanUpdateLog", mappedBy="changeTo")
*/
private $planUpdateLogsTo;
/**
* @ORM\Column(type="string", length=50)
*/
private $frequencyEn;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isOld;
public function __construct()
{
$this->subscriptionOrders = new ArrayCollection();
$this->planUpdateLogsFrom = new ArrayCollection();
$this->planUpdateLogsTo = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getStripeId(): ?string
{
return $this->stripeId;
}
public function setStripeId(string $stripeId): self
{
$this->stripeId = $stripeId;
return $this;
}
public function getFrequency(): ?string
{
return $this->frequency;
}
public function setFrequency(string $frequency): self
{
$this->frequency = $frequency;
return $this;
}
public function getPrice(): ?float
{
return $this->price;
}
public function setPrice(float $price): self
{
$this->price = round($price, 2);
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getCategory(): ?Category
{
return $this->category;
}
public function setCategory(?Category $category): self
{
$this->category = $category;
return $this;
}
/**
* @return Collection|SubscriptionOrder[]
*/
public function getSubscriptionOrders(): Collection
{
return $this->subscriptionOrders;
}
public function addSubscriptionOrder(SubscriptionOrder $subscriptionOrder): self
{
if (!$this->subscriptionOrders->contains($subscriptionOrder)) {
$this->subscriptionOrders[] = $subscriptionOrder;
$subscriptionOrder->setPlan($this);
}
return $this;
}
public function removeSubscriptionOrder(SubscriptionOrder $subscriptionOrder): self
{
if ($this->subscriptionOrders->contains($subscriptionOrder)) {
$this->subscriptionOrders->removeElement($subscriptionOrder);
// set the owning side to null (unless already changed)
if ($subscriptionOrder->getPlan() === $this) {
$subscriptionOrder->setPlan(null);
}
}
return $this;
}
public function getDurationPerWeek(): ?int
{
return $this->durationPerWeek;
}
public function setDurationPerWeek(int $durationPerWeek): self
{
$this->durationPerWeek = $durationPerWeek;
return $this;
}
/**
* @return Collection|PlanUpdateLog[]
*/
public function getPlanUpdateLogsFrom(): Collection
{
return $this->planUpdateLogsFrom;
}
public function addPlanUpdateLogFrom(PlanUpdateLog $planUpdateLogFrom): self
{
if (!$this->planUpdateLogsFrom->contains($planUpdateLogFrom)) {
$this->planUpdateLogsFrom[] = $planUpdateLogFrom;
$planUpdateLogFrom->setChangeFrom($this);
}
return $this;
}
public function removePlanUpdateLogFrom(PlanUpdateLog $planUpdateLogFrom): self
{
if ($this->planUpdateLogsFrom->contains($planUpdateLogFrom)) {
$this->planUpdateLogsFrom->removeElement($planUpdateLogFrom);
// set the owning side to null (unless already changed)
if ($planUpdateLogFrom->getChangeFrom() === $this) {
$planUpdateLogFrom->setChangeFrom(null);
}
}
return $this;
}
public function getPlanUpdateLogsTo()
{
return $this->planUpdateLogsTo;
}
public function addPlanUpdateLogTo(PlanUpdateLog $planUpdateLogTo): self
{
if (!$this->planUpdateLogsTo->contains($planUpdateLogTo)) {
$this->planUpdateLogsTo[] = $planUpdateLogTo;
$planUpdateLogTo->setChangeFrom($this);
}
return $this;
}
public function removePlanUpdateLogTo(PlanUpdateLog $planUpdateLogTo): self
{
if ($this->planUpdateLogsTo->contains($planUpdateLogTo)) {
$this->planUpdateLogsTo->removeElement($planUpdateLogTo);
// set the owning side to null (unless already changed)
if ($planUpdateLogTo->getChangeFrom() === $this) {
$planUpdateLogTo->setChangeFrom(null);
}
}
return $this;
}
public function __toString()
{
return $this->getFrequency();
}
public function getFrequencyEn(): ?string
{
return $this->frequencyEn;
}
public function setFrequencyEn(?string $frequencyEn): self
{
$this->frequencyEn = $frequencyEn;
return $this;
}
public function getIsOld(): ?bool
{
return $this->isOld;
}
public function setIsOld(?bool $isOld): self
{
$this->isOld = $isOld;
return $this;
}
}