<?php
namespace App\Entity;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\CouponRepository")
*/
class Coupon
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="boolean")
*/
private $isGeneratedPromoCode;
/**
* @ORM\Column(type="string", length=10, nullable=false)
*/
private $promoCode;
/**
* @ORM\Column(type="datetime", nullable=false)
*/
private $expiresAt;
/**
* @ORM\Column(type="integer")
*/
private $limitUses;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Customer")
* @ORM\JoinTable(name="coupon_customer")
*/
private $customers;
/**
* @ORM\OneToMany(targetEntity="App\Entity\CouponCustomer", mappedBy="coupon", orphanRemoval=true)
*/
private $couponCustomers;
/**
* @var integer
*/
private $activatedUses;
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @return mixed
*/
public function getPromoCode()
{
return $this->promoCode;
}
/**
* @param mixed $promoCode
* @return Coupon
*/
public function setPromoCode($promoCode)
{
$this->promoCode = $promoCode;
return $this;
}
/**
* @return mixed
*/
public function getIsGeneratedPromoCode()
{
return $this->isGeneratedPromoCode;
}
/**
* @param $isGeneratedPromoCode
* @return Coupon
*/
public function setIsGeneratedPromoCode($isGeneratedPromoCode)
{
$this->isGeneratedPromoCode = $isGeneratedPromoCode;
return $this;
}
/**
* @return mixed
*/
public function getExpiresAt()
{
return $this->expiresAt;
}
/**
* @param mixed $expiresAt
* @return Coupon
*/
public function setExpiresAt($expiresAt)
{
$this->expiresAt = $expiresAt;
return $this;
}
/**
* @return mixed
*/
public function getLimitUses()
{
return $this->limitUses;
}
/**
* @param mixed $limitUses
* @return Coupon
*/
public function setLimitUses($limitUses)
{
$this->limitUses = $limitUses;
return $this;
}
/**
* @return mixed
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* @param mixed $createdAt
* @return Coupon
*/
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
/**
* @return mixed
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* @param mixed $updatedAt
* @return Coupon
*/
public function setUpdatedAt($updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* @return mixed
*/
public function __toString()
{
return self::getPromoCode();
}
/**
* @return Collection
*/
public function getCustomers(): ?Collection
{
return $this->customers;
}
/**
* @return Collection
*/
public function setCustomers(Collection $customers): void
{
$this->customers = $customers;
}
public function addCustomer($customer): self
{
if ( ! $this->customers->contains($customer)) {
$this->customers[] = $customer;
}
return $this;
}
public function removeCustomer($customer): self
{
$this->customers->removeElement($customer);
return $this;
}
/**
* @return Collection
*/
public function getCouponCustomers(): ?Collection
{
return $this->couponCustomers;
}
/**
* @return Collection
*/
public function setCouponCustomers(Collection $couponCustomers): void
{
$this->couponCustomers = $couponCustomers;
}
/**
* @return int
*/
public function getActivatedUses(): int
{
return count($this->couponCustomers);
}
/**
* @param int $activatedUses
*/
public function setActivatedUses(int $activatedUses): void
{
$this->activatedUses = $activatedUses;
}
}