<?php
namespace App\Entity;
use Knp\DoctrineBehaviors\Contract\Entity\SoftDeletableInterface;
use Knp\DoctrineBehaviors\Model\SoftDeletable\SoftDeletableTrait;
use Knp\DoctrineBehaviors\Model\Blameable\BlameableTrait;
use Knp\DoctrineBehaviors\Contract\Entity\BlameableInterface;
use Knp\DoctrineBehaviors\Model\Timestampable\TimestampableTrait;
use Knp\DoctrineBehaviors\Contract\Entity\TimestampableInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity
* @ORM\Table(name="rebate_code")
*/
class RebateCode implements BlameableInterface, TimestampableInterface, SoftDeletableInterface {
use BlameableTrait;
use TimestampableTrait;
use SoftDeletableTrait;
const CODE_TYPE_PERCENT = 'percent';
const CODE_TYPE_AMOUNT = 'amount';
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var string
*
* @ORM\Column(name="code_type", type="string", length=40, nullable=true)
*/
private $codeType;
/**
* @var string
*
* @ORM\Column(name="code", type="string", length=40, nullable=true)
*/
private $code;
/**
* @var int
*
* @ORM\Column(name="amount_of_codes", type="integer", length=40, nullable=true)
*/
private $amount;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User")
*/
private $user;
/**
* @var boolean
*
* @ORM\Column(name="multiple", type="boolean", nullable=true)
*/
private $multiple;
/**
* @var \DateTime
*
* @ORM\Column(name="used_date", type="datetime", nullable=true)
*/
private $usedDate;
/**
* @var \DateTime
*
* @ORM\Column(name="valid_to", type="datetime", nullable=true)
*/
private $validTo;
/**
* @Doctrine\ORM\Mapping\Column(type="decimal", precision=10, scale=2, nullable=true)
*/
protected $price;
/**
* @var integer
*
* @ORM\Column(name="percent", type="integer", length=255, nullable=true)
*/
private $percent;
/**
* @var boolean
*
* @ORM\Column(name="used", type="boolean", nullable=true)
*/
private $used;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Language")
* @ORM\JoinColumn(name="language", referencedColumnName="id")
*/
protected $language;
/**
* @var boolean
*
* @ORM\Column(name="include_invoice", type="boolean", nullable=true)
*/
private $includeInvoice = true;
/**
* @Doctrine\ORM\Mapping\ManyToMany(targetEntity="App\Entity\ProductProducer")
* @Doctrine\ORM\Mapping\JoinTable(name="rebate_code_product_producers_relation")
*/
private $productProducers;
/**
* @Doctrine\ORM\Mapping\ManyToMany(targetEntity="App\Entity\LandingPage")
* @Doctrine\ORM\Mapping\JoinTable(name="rebate_code_landing_page_relation")
*/
private $landingPages;
/**
* @Doctrine\ORM\Mapping\OneToMany(targetEntity="App\Entity\Order", mappedBy="rebateCode")
*/
protected $orders;
public static function getCodeTypes() {
return [
self::CODE_TYPE_AMOUNT => self::CODE_TYPE_AMOUNT,
self::CODE_TYPE_PERCENT => self::CODE_TYPE_PERCENT,
];
}
public function __toString()
{
return $this->getCode();
}
public function __construct()
{
$this->includeInvoice = true;
$this->productProducers = new ArrayCollection();
$this->landingPages = new ArrayCollection();
$this->orders = new ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set code
*
* @param string $code
*
* @return RebateCode
*/
public function setCode($code)
{
$this->code = $code;
return $this;
}
/**
* Get code
*
* @return string
*/
public function getCode()
{
return $this->code;
}
/**
* Set multiple
*
* @param boolean $multiple
*
* @return RebateCode
*/
public function setMultiple($multiple)
{
$this->multiple = $multiple;
return $this;
}
/**
* Get multiple
*
* @return boolean
*/
public function getMultiple()
{
return $this->multiple;
}
/**
* Set usedDate
*
* @param \DateTime $usedDate
*
* @return RebateCode
*/
public function setUsedDate($usedDate)
{
$this->usedDate = $usedDate;
return $this;
}
/**
* Get usedDate
*
* @return \DateTime
*/
public function getUsedDate()
{
return $this->usedDate;
}
/**
* Set validTo
*
* @param \DateTime $validTo
*
* @return RebateCode
*/
public function setValidTo($validTo)
{
$this->validTo = $validTo;
return $this;
}
/**
* Get validTo
*
* @return \DateTime
*/
public function getValidTo()
{
return $this->validTo;
}
/**
* Set price
*
* @param string $price
*
* @return RebateCode
*/
public function setPrice($price)
{
$this->price = $price;
return $this;
}
/**
* Get price
*
* @return string
*/
public function getPrice()
{
return $this->price;
}
/**
* Set percent
*
* @param integer $percent
*
* @return RebateCode
*/
public function setPercent($percent)
{
$this->percent = $percent;
return $this;
}
/**
* Get percent
*
* @return integer
*/
public function getPercent()
{
return $this->percent;
}
/**
* Set used
*
* @param boolean $used
*
* @return RebateCode
*/
public function setUsed($used)
{
$this->used = $used;
return $this;
}
/**
* Get used
*
* @return boolean
*/
public function getUsed()
{
return $this->used;
}
/**
* Set user
*
* @param \App\Entity\User $user
*
* @return RebateCode
*/
public function setUser(\App\Entity\User $user = null)
{
$this->user = $user;
return $this;
}
/**
* Get user
*
* @return \App\Entity\User
*/
public function getUser()
{
return $this->user;
}
/**
* Set codeType
*
* @param string $codeType
*
* @return RebateCode
*/
public function setCodeType($codeType)
{
$this->codeType = $codeType;
return $this;
}
/**
* Get codeType
*
* @return string
*/
public function getCodeType()
{
return $this->codeType;
}
/**
* Set includeInvoice
*
* @param boolean $includeInvoice
*
* @return RebateCode
*/
public function setIncludeInvoice($includeInvoice)
{
$this->includeInvoice = $includeInvoice;
return $this;
}
/**
* Get includeInvoice
*
* @return boolean
*/
public function getIncludeInvoice()
{
return $this->includeInvoice;
}
public function getLanguage(): ?Language
{
return $this->language;
}
public function setLanguage(?Language $language): self
{
$this->language = $language;
return $this;
}
/**
* @return Collection|ProductProducer[]
*/
public function getProductProducers(): Collection
{
return $this->productProducers;
}
public function addProductProducer(ProductProducer $productProducer): self
{
if (!$this->productProducers->contains($productProducer)) {
$this->productProducers[] = $productProducer;
}
return $this;
}
public function removeProductProducer(ProductProducer $productProducer): self
{
if ($this->productProducers->contains($productProducer)) {
$this->productProducers->removeElement($productProducer);
}
return $this;
}
/**
* @return Collection|LandingPage[]
*/
public function getLandingPages(): Collection
{
return $this->landingPages;
}
public function addLandingPage(LandingPage $landingPage): self
{
if (!$this->landingPages->contains($landingPage)) {
$this->landingPages[] = $landingPage;
}
return $this;
}
public function removeLandingPage(LandingPage $landingPage): self
{
if ($this->landingPages->contains($landingPage)) {
$this->landingPages->removeElement($landingPage);
}
return $this;
}
/**
* @return Collection|Order[]
*/
public function getOrders(): Collection
{
return $this->orders;
}
public function addOrder(Order $order): self
{
if (!$this->orders->contains($order)) {
$this->orders[] = $order;
$order->setRebateCode($this);
}
return $this;
}
public function removeOrder(Order $order): self
{
if ($this->orders->contains($order)) {
$this->orders->removeElement($order);
// set the owning side to null (unless already changed)
if ($order->getRebateCode() === $this) {
$order->setRebateCode(null);
}
}
return $this;
}
/**
* @return int
*/
public function getAmount()
{
return $this->amount;
}
/**
* @param int $amount
*/
public function setAmount($amount)
{
$this->amount = $amount;
}
}