<?php
namespace App\Entity;
use App\Repository\SubscriptionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: SubscriptionRepository::class)]
class Subscription
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\ManyToOne(targetEntity: Offer::class, inversedBy: 'subscriptions')]
private $offer;
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'subscriptions')]
private $pro;
#[ORM\Column(type: 'date')]
private $start;
#[ORM\Column(type: 'date')]
private $end;
#[ORM\Column(type: 'string', length: 255)]
private $status;
#[ORM\Column(type: 'string', length: 255)]
private $stripeSubscriptionId;
#[ORM\Column(type: 'boolean', nullable: true)]
private $trial;
#[ORM\Column(type: 'date', nullable: true)]
private $trialEnd;
#[ORM\Column(type: 'datetime', nullable: true)]
private $endedAt;
#[ORM\Column(type: 'boolean')]
private $isFirstTime;
#[ORM\ManyToOne(targetEntity: DiscountCode::class, inversedBy: 'subscriptions')]
private $discount;
#[ORM\Column(type: 'date', nullable: true)]
private $discountEnd;
#[ORM\Column(type: 'date', nullable: true)]
private $createdAt;
#[ORM\OneToMany(mappedBy: 'subscription', targetEntity: Invoice::class)]
private Collection $invoices;
public function __construct()
{
$this->invoices = new ArrayCollection();
}
public function __clone() {
$this->id = null;
}
public function getId(): ?int
{
return $this->id;
}
public function getOffer(): ?Offer
{
return $this->offer;
}
public function setOffer(?Offer $offer): self
{
$this->offer = $offer;
return $this;
}
public function getPro(): ?User
{
return $this->pro;
}
public function setPro(?User $pro): self
{
$this->pro = $pro;
return $this;
}
public function getStart(): ?\DateTimeInterface
{
return $this->start;
}
public function setStart(\DateTimeInterface $start): self
{
$this->start = $start;
return $this;
}
public function getEnd(): ?\DateTimeInterface
{
return $this->end;
}
public function setEnd(\DateTimeInterface $end): self
{
$this->end = $end;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(string $status): self
{
$this->status = $status;
return $this;
}
public function getStripeSubscriptionId(): ?string
{
return $this->stripeSubscriptionId;
}
public function setStripeSubscriptionId(string $stripeSubscriptionId): self
{
$this->stripeSubscriptionId = $stripeSubscriptionId;
return $this;
}
public function getTrial(): ?bool
{
return $this->trial;
}
public function setTrial(?bool $trial): self
{
$this->trial = $trial;
return $this;
}
public function getTrialEnd(): ?\DateTimeInterface
{
return $this->trialEnd;
}
public function setTrialEnd(?\DateTimeInterface $trialEnd): self
{
$this->trialEnd = $trialEnd;
return $this;
}
public function getEndedAt(): ?\DateTimeInterface
{
return $this->endedAt;
}
public function setEndedAt(?\DateTimeInterface $endedAt): self
{
$this->endedAt = $endedAt;
return $this;
}
public function getIsFirstTime(): ?bool
{
return $this->isFirstTime;
}
public function setIsFirstTime(bool $isFirstTime): self
{
$this->isFirstTime = $isFirstTime;
return $this;
}
public function getDiscount(): ?DiscountCode
{
return $this->discount;
}
public function setDiscount(?DiscountCode $discount): self
{
$this->discount = $discount;
return $this;
}
public function getDiscountEnd(): ?\DateTimeInterface
{
return $this->discountEnd;
}
public function setDiscountEnd(?\DateTimeInterface $discountEnd): self
{
$this->discountEnd = $discountEnd;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
/**
* @return Collection<int, Invoice>
*/
public function getInvoices(): Collection
{
return $this->invoices;
}
public function addInvoice(Invoice $invoice): static
{
if (!$this->invoices->contains($invoice)) {
$this->invoices->add($invoice);
$invoice->setSubscription($this);
}
return $this;
}
public function removeInvoice(Invoice $invoice): static
{
if ($this->invoices->removeElement($invoice)) {
// set the owning side to null (unless already changed)
if ($invoice->getSubscription() === $this) {
$invoice->setSubscription(null);
}
}
return $this;
}
}