<?php
namespace App\Entity;
use App\Repository\PromoCodeUsageRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=PromoCodeUsageRepository::class)
*/
class PromoCodeUsage
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="date_immutable")
*/
private $fechaDeUso;
/**
* @ORM\ManyToOne(targetEntity=PromoCode::class, inversedBy="promoCodeUsages", cascade={"persist"})
*/
private $promoCode;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $platformFee;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $commission;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isPayed;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $inPayout;
/**
* @ORM\ManyToOne(targetEntity=Payout::class, inversedBy="promoCodeUsages")
*/
private $payout;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $currentPlace;
/**
* @ORM\OneToOne(targetEntity=Subscription::class, inversedBy="promoCodeUsage", cascade={"persist", "remove"})
*/
private $subscription;
public function __construct()
{
if(!$this->fechaDeUso) $this->setFechaDeUso(new \DateTimeImmutable());
}
public function getId(): ?int
{
return $this->id;
}
public function getFechaDeUso(): ?\DateTimeImmutable
{
return $this->fechaDeUso;
}
public function setFechaDeUso(\DateTimeImmutable $fechaDeUso): self
{
$this->fechaDeUso = $fechaDeUso;
return $this;
}
public function getPromoCode(): ?PromoCode
{
return $this->promoCode;
}
public function setPromoCode(?PromoCode $promoCode): self
{
$this->promoCode = $promoCode;
return $this;
}
public function getPromoCodeUser()
{
return $this->getPromoCode()->getUser();
}
public function getPlatformFee(): ?int
{
return $this->platformFee;
}
public function setPlatformFee(?int $platformFee): self
{
$this->platformFee = $platformFee;
return $this;
}
public function getCommission(): ?int
{
return $this->commission;
}
public function setCommission(?int $commission): self
{
$this->commission = $commission;
return $this;
}
public function getIsPayed(): ?bool
{
return $this->isPayed;
}
public function setIsPayed(?bool $isPayed): self
{
$this->isPayed = $isPayed;
return $this;
}
public function isInPayout(): ?bool
{
return $this->inPayout;
}
public function setInPayout(?bool $inPayout): self
{
$this->inPayout = $inPayout;
return $this;
}
public function getPayout(): ?Payout
{
return $this->payout;
}
public function setPayout(?Payout $payout): self
{
$this->payout = $payout;
return $this;
}
public function getCurrentPlace(): ?string
{
return $this->currentPlace;
}
public function setCurrentPlace(?string $currentPlace): self
{
$this->currentPlace = $currentPlace;
return $this;
}
public function __toString()
{
return $this->getFechaDeUso()->format('d M Y');
}
public function getSubscription(): ?Subscription
{
return $this->subscription;
}
public function setSubscription(?Subscription $subscription): self
{
$this->subscription = $subscription;
return $this;
}
}