<?php
namespace App\Entity;
use App\Repository\PayoutRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=PayoutRepository::class)
*/
class Payout
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $amt;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isPayed;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="payouts")
*/
private $seller;
/**
* @ORM\ManyToOne(targetEntity=PromoCode::class)
*/
private $promoCode;
/**
* @ORM\OneToMany(targetEntity=PromoCodeUsage::class, mappedBy="payout")
*/
private $promoCodeUsages;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
private $createdAt;
/**
* @ORM\ManyToOne(targetEntity=PaymentMethod::class)
*/
private $paymentMethod;
/**
* @ORM\Column(type="string", length=1000, nullable=true)
*/
private $comentarios;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $currentPlace;
public function __construct()
{
$this->promoCodeUsages = new ArrayCollection();
if(!$this->createdAt) $this->setCreatedAt(new \DateTimeImmutable());
if(!$this->currentPlace) $this->setCurrentPlace('unpaid');
}
public function getId(): ?int
{
return $this->id;
}
public function getAmt(): ?float
{
return $this->amt;
}
public function setAmt(?float $amt): self
{
$this->amt = $amt;
return $this;
}
public function isIsPayed(): ?bool
{
return $this->isPayed;
}
public function setIsPayed(?bool $isPayed): self
{
$this->isPayed = $isPayed;
return $this;
}
public function getSeller(): ?User
{
return $this->seller;
}
public function setSeller(?User $seller): self
{
$this->seller = $seller;
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();
}
/**
* @return Collection<int, PromoCodeUsage>
*/
public function getPromoCodeUsages(): Collection
{
return $this->promoCodeUsages;
}
public function addPromoCodeUsage(PromoCodeUsage $promoCodeUsage): self
{
if (!$this->promoCodeUsages->contains($promoCodeUsage)) {
$this->promoCodeUsages[] = $promoCodeUsage;
$promoCodeUsage->setPayout($this);
}
return $this;
}
public function removePromoCodeUsage(PromoCodeUsage $promoCodeUsage): self
{
if ($this->promoCodeUsages->removeElement($promoCodeUsage)) {
// set the owning side to null (unless already changed)
if ($promoCodeUsage->getPayout() === $this) {
$promoCodeUsage->setPayout(null);
}
}
return $this;
}
public function __toString()
{
return $this->getPromoCode()->getContent();
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getPaymentMethod(): ?PaymentMethod
{
return $this->paymentMethod;
}
public function setPaymentMethod(?PaymentMethod $paymentMethod): self
{
$this->paymentMethod = $paymentMethod;
return $this;
}
public function getComentarios(): ?string
{
return $this->comentarios;
}
public function setComentarios(?string $comentarios): self
{
$this->comentarios = $comentarios;
return $this;
}
public function getCurrentPlace(): ?string
{
return $this->currentPlace;
}
public function setCurrentPlace(?string $currentPlace): self
{
$this->currentPlace = $currentPlace;
return $this;
}
}