src/Entity/RebateCode.php line 30

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Knp\DoctrineBehaviors\Contract\Entity\SoftDeletableInterface;
  4. use Knp\DoctrineBehaviors\Model\SoftDeletable\SoftDeletableTrait;
  5. use Knp\DoctrineBehaviors\Model\Blameable\BlameableTrait;
  6. use Knp\DoctrineBehaviors\Contract\Entity\BlameableInterface;
  7. use Knp\DoctrineBehaviors\Model\Timestampable\TimestampableTrait;
  8. use Knp\DoctrineBehaviors\Contract\Entity\TimestampableInterface;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. use Symfony\Component\HttpFoundation\File\UploadedFile;
  14. use Symfony\Component\HttpFoundation\File\File;
  15. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  16. /**
  17.  * @ORM\Entity
  18.  * @ORM\Table(name="rebate_code")
  19.  */
  20. class RebateCode implements BlameableInterfaceTimestampableInterfaceSoftDeletableInterface  {
  21.     use BlameableTrait;
  22.     use TimestampableTrait;
  23.     
  24.     use SoftDeletableTrait;
  25.     
  26. const CODE_TYPE_PERCENT 'percent';
  27.     const CODE_TYPE_AMOUNT 'amount';
  28.     
  29.     
  30.     /**
  31.      * @ORM\Id
  32.      * @ORM\Column(type="integer")
  33.      * @ORM\GeneratedValue(strategy="AUTO")
  34.      */
  35.     protected $id;
  36.     /**
  37.      * @var string
  38.      *
  39.      * @ORM\Column(name="code_type", type="string", length=40, nullable=true)
  40.      */
  41.     private $codeType;
  42.     /**
  43.      * @var string
  44.      *
  45.      * @ORM\Column(name="code", type="string", length=40, nullable=true)
  46.      */
  47.     private $code;
  48.     /**
  49.      * @var int
  50.      *
  51.      * @ORM\Column(name="amount_of_codes", type="integer", length=40, nullable=true)
  52.      */
  53.     private $amount;
  54.     /**
  55.      * @ORM\ManyToOne(targetEntity="App\Entity\User")
  56.      */
  57.     private $user;
  58.     /**
  59.      * @var boolean
  60.      *
  61.      * @ORM\Column(name="multiple", type="boolean", nullable=true)
  62.      */
  63.     private $multiple;
  64.     /**
  65.      * @var \DateTime
  66.      *
  67.      * @ORM\Column(name="used_date", type="datetime", nullable=true)
  68.      */
  69.     private $usedDate;
  70.     /**
  71.      * @var \DateTime
  72.      *
  73.      * @ORM\Column(name="valid_to", type="datetime", nullable=true)
  74.      */
  75.     private $validTo;
  76.     /**
  77.      * @Doctrine\ORM\Mapping\Column(type="decimal", precision=10, scale=2, nullable=true)
  78.      */
  79.     protected $price;
  80.     /**
  81.      * @var integer
  82.      *
  83.      * @ORM\Column(name="percent", type="integer", length=255, nullable=true)
  84.      */
  85.     private $percent;
  86.     /**
  87.      * @var boolean
  88.      *
  89.      * @ORM\Column(name="used", type="boolean", nullable=true)
  90.      */
  91.     private $used;
  92.     /**
  93.      * @ORM\ManyToOne(targetEntity="App\Entity\Language")
  94.      * @ORM\JoinColumn(name="language", referencedColumnName="id")
  95.      */
  96.     protected $language;
  97.     /**
  98.      * @var boolean
  99.      *
  100.      * @ORM\Column(name="include_invoice", type="boolean", nullable=true)
  101.      */
  102.     private $includeInvoice true;
  103.     /**
  104.      * @Doctrine\ORM\Mapping\ManyToMany(targetEntity="App\Entity\ProductProducer")
  105.      * @Doctrine\ORM\Mapping\JoinTable(name="rebate_code_product_producers_relation")
  106.      */
  107.     private $productProducers;
  108.     /**
  109.      * @Doctrine\ORM\Mapping\ManyToMany(targetEntity="App\Entity\LandingPage")
  110.      * @Doctrine\ORM\Mapping\JoinTable(name="rebate_code_landing_page_relation")
  111.      */
  112.     private $landingPages;
  113.     /**
  114.      * @Doctrine\ORM\Mapping\OneToMany(targetEntity="App\Entity\Order", mappedBy="rebateCode")
  115.      */
  116.     protected $orders;
  117.     public static function getCodeTypes() {
  118.         return [
  119.             self::CODE_TYPE_AMOUNT => self::CODE_TYPE_AMOUNT,
  120.             self::CODE_TYPE_PERCENT => self::CODE_TYPE_PERCENT,
  121.         ];
  122.     }
  123.     public function __toString()
  124.     {
  125.         return $this->getCode();
  126.     }
  127.     public function __construct()
  128.     {
  129.         $this->includeInvoice true;
  130.         $this->productProducers = new ArrayCollection();
  131.         $this->landingPages = new ArrayCollection();
  132.         $this->orders = new ArrayCollection();
  133.     }
  134.     /**
  135.      * Get id
  136.      *
  137.      * @return integer
  138.      */
  139.     public function getId()
  140.     {
  141.         return $this->id;
  142.     }
  143.     /**
  144.      * Set code
  145.      *
  146.      * @param string $code
  147.      *
  148.      * @return RebateCode
  149.      */
  150.     public function setCode($code)
  151.     {
  152.         $this->code $code;
  153.         return $this;
  154.     }
  155.     /**
  156.      * Get code
  157.      *
  158.      * @return string
  159.      */
  160.     public function getCode()
  161.     {
  162.         return $this->code;
  163.     }
  164.     /**
  165.      * Set multiple
  166.      *
  167.      * @param boolean $multiple
  168.      *
  169.      * @return RebateCode
  170.      */
  171.     public function setMultiple($multiple)
  172.     {
  173.         $this->multiple $multiple;
  174.         return $this;
  175.     }
  176.     /**
  177.      * Get multiple
  178.      *
  179.      * @return boolean
  180.      */
  181.     public function getMultiple()
  182.     {
  183.         return $this->multiple;
  184.     }
  185.     /**
  186.      * Set usedDate
  187.      *
  188.      * @param \DateTime $usedDate
  189.      *
  190.      * @return RebateCode
  191.      */
  192.     public function setUsedDate($usedDate)
  193.     {
  194.         $this->usedDate $usedDate;
  195.         return $this;
  196.     }
  197.     /**
  198.      * Get usedDate
  199.      *
  200.      * @return \DateTime
  201.      */
  202.     public function getUsedDate()
  203.     {
  204.         return $this->usedDate;
  205.     }
  206.     /**
  207.      * Set validTo
  208.      *
  209.      * @param \DateTime $validTo
  210.      *
  211.      * @return RebateCode
  212.      */
  213.     public function setValidTo($validTo)
  214.     {
  215.         $this->validTo $validTo;
  216.         return $this;
  217.     }
  218.     /**
  219.      * Get validTo
  220.      *
  221.      * @return \DateTime
  222.      */
  223.     public function getValidTo()
  224.     {
  225.         return $this->validTo;
  226.     }
  227.     /**
  228.      * Set price
  229.      *
  230.      * @param string $price
  231.      *
  232.      * @return RebateCode
  233.      */
  234.     public function setPrice($price)
  235.     {
  236.         $this->price $price;
  237.         return $this;
  238.     }
  239.     /**
  240.      * Get price
  241.      *
  242.      * @return string
  243.      */
  244.     public function getPrice()
  245.     {
  246.         return $this->price;
  247.     }
  248.     /**
  249.      * Set percent
  250.      *
  251.      * @param integer $percent
  252.      *
  253.      * @return RebateCode
  254.      */
  255.     public function setPercent($percent)
  256.     {
  257.         $this->percent $percent;
  258.         return $this;
  259.     }
  260.     /**
  261.      * Get percent
  262.      *
  263.      * @return integer
  264.      */
  265.     public function getPercent()
  266.     {
  267.         return $this->percent;
  268.     }
  269.     /**
  270.      * Set used
  271.      *
  272.      * @param boolean $used
  273.      *
  274.      * @return RebateCode
  275.      */
  276.     public function setUsed($used)
  277.     {
  278.         $this->used $used;
  279.         return $this;
  280.     }
  281.     /**
  282.      * Get used
  283.      *
  284.      * @return boolean
  285.      */
  286.     public function getUsed()
  287.     {
  288.         return $this->used;
  289.     }
  290.     /**
  291.      * Set user
  292.      *
  293.      * @param \App\Entity\User $user
  294.      *
  295.      * @return RebateCode
  296.      */
  297.     public function setUser(\App\Entity\User $user null)
  298.     {
  299.         $this->user $user;
  300.         return $this;
  301.     }
  302.     /**
  303.      * Get user
  304.      *
  305.      * @return \App\Entity\User
  306.      */
  307.     public function getUser()
  308.     {
  309.         return $this->user;
  310.     }
  311.     /**
  312.      * Set codeType
  313.      *
  314.      * @param string $codeType
  315.      *
  316.      * @return RebateCode
  317.      */
  318.     public function setCodeType($codeType)
  319.     {
  320.         $this->codeType $codeType;
  321.         return $this;
  322.     }
  323.     /**
  324.      * Get codeType
  325.      *
  326.      * @return string
  327.      */
  328.     public function getCodeType()
  329.     {
  330.         return $this->codeType;
  331.     }
  332.     /**
  333.      * Set includeInvoice
  334.      *
  335.      * @param boolean $includeInvoice
  336.      *
  337.      * @return RebateCode
  338.      */
  339.     public function setIncludeInvoice($includeInvoice)
  340.     {
  341.         $this->includeInvoice $includeInvoice;
  342.         return $this;
  343.     }
  344.     /**
  345.      * Get includeInvoice
  346.      *
  347.      * @return boolean
  348.      */
  349.     public function getIncludeInvoice()
  350.     {
  351.         return $this->includeInvoice;
  352.     }
  353.     public function getLanguage(): ?Language
  354.     {
  355.         return $this->language;
  356.     }
  357.     public function setLanguage(?Language $language): self
  358.     {
  359.         $this->language $language;
  360.         return $this;
  361.     }
  362.     /**
  363.      * @return Collection|ProductProducer[]
  364.      */
  365.     public function getProductProducers(): Collection
  366.     {
  367.         return $this->productProducers;
  368.     }
  369.     public function addProductProducer(ProductProducer $productProducer): self
  370.     {
  371.         if (!$this->productProducers->contains($productProducer)) {
  372.             $this->productProducers[] = $productProducer;
  373.         }
  374.         return $this;
  375.     }
  376.     public function removeProductProducer(ProductProducer $productProducer): self
  377.     {
  378.         if ($this->productProducers->contains($productProducer)) {
  379.             $this->productProducers->removeElement($productProducer);
  380.         }
  381.         return $this;
  382.     }
  383.     /**
  384.      * @return Collection|LandingPage[]
  385.      */
  386.     public function getLandingPages(): Collection
  387.     {
  388.         return $this->landingPages;
  389.     }
  390.     public function addLandingPage(LandingPage $landingPage): self
  391.     {
  392.         if (!$this->landingPages->contains($landingPage)) {
  393.             $this->landingPages[] = $landingPage;
  394.         }
  395.         return $this;
  396.     }
  397.     public function removeLandingPage(LandingPage $landingPage): self
  398.     {
  399.         if ($this->landingPages->contains($landingPage)) {
  400.             $this->landingPages->removeElement($landingPage);
  401.         }
  402.         return $this;
  403.     }
  404.     /**
  405.      * @return Collection|Order[]
  406.      */
  407.     public function getOrders(): Collection
  408.     {
  409.         return $this->orders;
  410.     }
  411.     public function addOrder(Order $order): self
  412.     {
  413.         if (!$this->orders->contains($order)) {
  414.             $this->orders[] = $order;
  415.             $order->setRebateCode($this);
  416.         }
  417.         return $this;
  418.     }
  419.     public function removeOrder(Order $order): self
  420.     {
  421.         if ($this->orders->contains($order)) {
  422.             $this->orders->removeElement($order);
  423.             // set the owning side to null (unless already changed)
  424.             if ($order->getRebateCode() === $this) {
  425.                 $order->setRebateCode(null);
  426.             }
  427.         }
  428.         return $this;
  429.     }
  430.     /**
  431.      * @return int
  432.      */
  433.     public function getAmount()
  434.     {
  435.         return $this->amount;
  436.     }
  437.     /**
  438.      * @param int $amount
  439.      */
  440.     public function setAmount($amount)
  441.     {
  442.         $this->amount $amount;
  443.     }
  444. }