src/Entity/System/CodeDiscount.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\System;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * Class CodeDiscount
  7.  *
  8.  * @ORM\Table(name="code_discount")
  9.  *
  10.  * @ORM\Entity(repositoryClass="App\Repository\System\CodeDiscountRepository")
  11.  */
  12. class CodeDiscount
  13. {
  14.     /**
  15.      * @ORM\Id()
  16.      *
  17.      * @ORM\GeneratedValue()
  18.      *
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @var string
  24.      *
  25.      * @ORM\Column (type="string", length=30, unique=true)
  26.      */
  27.     private $code;
  28.     /**
  29.      * @var bool
  30.      *
  31.      * @ORM\Column (type="boolean")
  32.      */
  33.     private $active;
  34.     /**
  35.      * @var Customer|null
  36.      *
  37.      * @ORM\ManyToOne(targetEntity="App\Entity\System\Customer", inversedBy="customerApi")
  38.      *
  39.      * @ORM\JoinColumn(name="customer", referencedColumnName="id_customer")
  40.      */
  41.     private $customer;
  42.     /**
  43.      * @ORM\Column(type="integer", nullable=true)
  44.      */
  45.     private ?int $redeemLimit null;
  46.     /**
  47.      * @ORM\Column(type="integer", nullable=true)
  48.      */
  49.     private ?int $redeemLimitByCustomer null;
  50.     /**
  51.      * @var float
  52.      *
  53.      * @ORM\Column(type="decimal", precision=20, scale=6, options={"default" : 0.000000})
  54.      */
  55.     private $discount;
  56.     /**
  57.      * @var \DateTime
  58.      *
  59.      * @ORM\Column(type="datetime", nullable=true)
  60.      */
  61.     private $dateExpiration;
  62.     /**
  63.      * @var \DateTime|null
  64.      *
  65.      * @ORM\Column(type="datetime")
  66.      */
  67.     private $dateStarting;
  68.     /**
  69.      * @var Order[]|ArrayCollection
  70.      *
  71.      * @ORM\OneToMany(targetEntity="App\Entity\System\Order", mappedBy="idVoucher")
  72.      */
  73.     private $orders;
  74.     /**
  75.      * @var ArrayCollection<int, CodeDiscountRule>|CodeDiscountRule[]
  76.      *
  77.      * @ORM\ManyToMany(targetEntity="CodeDiscountRule", inversedBy="codeDiscounts")
  78.      */
  79.     private $codeDiscountRules;
  80.     public function __construct()
  81.     {
  82.         $this->orders = new ArrayCollection();
  83.         $this->codeDiscountRules = new ArrayCollection();
  84.     }
  85.     /**
  86.      * @return mixed
  87.      */
  88.     public function getId()
  89.     {
  90.         return $this->id;
  91.     }
  92.     /**
  93.      * @return string
  94.      */
  95.     public function getCode(): string
  96.     {
  97.         return $this->code;
  98.     }
  99.     /**
  100.      * @return bool
  101.      */
  102.     public function isActive(): bool
  103.     {
  104.         return $this->active;
  105.     }
  106.     /**
  107.      * @return Customer|null
  108.      */
  109.     public function getCustomer(): ?Customer
  110.     {
  111.         return $this->customer;
  112.     }
  113.     /**
  114.      * @return float
  115.      */
  116.     public function getDiscount(): float
  117.     {
  118.         return $this->discount;
  119.     }
  120.     /**
  121.      * @return \DateTime|null
  122.      */
  123.     public function getDateExpiration(): ?\DateTime
  124.     {
  125.         return $this->dateExpiration;
  126.     }
  127.     /**
  128.      * @return \DateTime
  129.      */
  130.     public function getDateStarting(): \DateTime
  131.     {
  132.         return $this->dateStarting;
  133.     }
  134.     /**
  135.      * @return Order[]|ArrayCollection
  136.      */
  137.     public function getOrders()
  138.     {
  139.         return $this->orders;
  140.     }
  141.     /**
  142.      * @param Order[]|ArrayCollection $orders
  143.      */
  144.     public function setOrders($orders): self
  145.     {
  146.         $this->orders $orders;
  147.         return $this;
  148.     }
  149.     public function setCode(string $code): CodeDiscount
  150.     {
  151.         $this->code $code;
  152.         return $this;
  153.     }
  154.     public function setActive(bool $active): CodeDiscount
  155.     {
  156.         $this->active $active;
  157.         return $this;
  158.     }
  159.     public function setCustomer(?Customer $customer): CodeDiscount
  160.     {
  161.         $this->customer $customer;
  162.         return $this;
  163.     }
  164.     public function setDiscount(float $discount): CodeDiscount
  165.     {
  166.         $this->discount $discount;
  167.         return $this;
  168.     }
  169.     public function setDateExpiration(?\DateTime $dateExpiration): CodeDiscount
  170.     {
  171.         $this->dateExpiration $dateExpiration;
  172.         return $this;
  173.     }
  174.     public function setDateStarting(?\DateTime $dateStarting): CodeDiscount
  175.     {
  176.         $this->dateStarting $dateStarting;
  177.         return $this;
  178.     }
  179.     /**
  180.      * @return CodeDiscountRule[]|ArrayCollection<int, CodeDiscountRule>
  181.      */
  182.     public function getCodeDiscountRules()
  183.     {
  184.         return $this->codeDiscountRules;
  185.     }
  186.     public function hasCodeDiscountRule(int $codeDiscountRuleId): bool
  187.     {
  188.         foreach ($this->codeDiscountRules as $codeDiscountRule) {
  189.             if ($codeDiscountRule->getId() === $codeDiscountRuleId) {
  190.                 return true;
  191.             }
  192.         }
  193.         return false;
  194.     }
  195.     public function addCodeDiscountRule(CodeDiscountRule $codeDiscountRule): CodeDiscount
  196.     {
  197.         if (!$this->codeDiscountRules->contains($codeDiscountRule)) {
  198.             $this->codeDiscountRules[] = $codeDiscountRule;
  199.         }
  200.         return $this;
  201.     }
  202.     /**
  203.      * @param CodeDiscountRule[]|ArrayCollection<int, CodeDiscountRule> $codeDiscountRules
  204.      */
  205.     public function setCodeDiscountRules($codeDiscountRules): CodeDiscount
  206.     {
  207.         $this->codeDiscountRules $codeDiscountRules;
  208.         return $this;
  209.     }
  210.     public function getRedeemLimit(): ?int
  211.     {
  212.         return $this->redeemLimit;
  213.     }
  214.     public function setRedeemLimit(?int $redeemLimit): CodeDiscount
  215.     {
  216.         $this->redeemLimit $redeemLimit;
  217.         return $this;
  218.     }
  219.     public function getRedeemLimitByCustomer(): ?int
  220.     {
  221.         return $this->redeemLimitByCustomer;
  222.     }
  223.     public function setRedeemLimitByCustomer(?int $redeemLimitByCustomer): CodeDiscount
  224.     {
  225.         $this->redeemLimitByCustomer $redeemLimitByCustomer;
  226.         return $this;
  227.     }
  228. }