src/Modules/VoucherCart/Entity/VoucherOrderVoucher.php line 16

  1. <?php
  2. namespace App\Modules\VoucherCart\Entity;
  3. use App\Admin\Modules\Voucher\Entity\VoucherPackage;
  4. use App\Admin\Modules\Voucher\Entity\VoucherPackageVoucher;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. /**
  10.  * @ORM\Table(name="voucher_order_voucher", indexes={@ORM\Index(columns={"name"}), @ORM\Index(columns={"type"}), @ORM\Index(columns={"price"}), @ORM\Index(columns={"total_price"})})
  11.  * @ORM\Entity
  12.  */
  13. class VoucherOrderVoucher
  14. {
  15.     const TYPE_AMOUNT 1;
  16.     const TYPE_PREDEFINED 2;
  17.     /**
  18.      * @var int
  19.      *
  20.      * @ORM\Id
  21.      * @ORM\Column(type="bigint", options={"unsigned"=true}))
  22.      * @ORM\GeneratedValue(strategy="AUTO")
  23.      */
  24.     private $id;
  25.     
  26.     /**
  27.      * @var \App\Modules\VoucherCart\Entity\VoucherOrder
  28.      *
  29.      * @ORM\ManyToOne(targetEntity="App\Modules\VoucherCart\Entity\VoucherOrder", inversedBy="vouchers")
  30.      * @ORM\JoinColumns({
  31.      *   @ORM\JoinColumn(name="id_voucher_order", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  32.      * })
  33.      */
  34.     private $order;
  35.     
  36.     /**
  37.      * @var \App\Admin\Modules\Voucher\Entity\VoucherPackage
  38.      *
  39.      * @ORM\ManyToOne(targetEntity="App\Admin\Modules\Voucher\Entity\VoucherPackage")
  40.      * @ORM\JoinColumns({
  41.      *   @ORM\JoinColumn(name="id_voucher_package", referencedColumnName="id", nullable=true, onDelete="SET NULL")
  42.      * })
  43.      */
  44.     private $package;
  45.     
  46.     /**
  47.      * @var string
  48.      *
  49.      * @ORM\Column(name="name", type="string", length=255, nullable=true, options={"collation"="utf8_unicode_ci"})
  50.      */
  51.     private $name;
  52.     
  53.     /**
  54.      * @var int
  55.      *
  56.      * @ORM\Column(name="type", type="smallint", nullable=false)
  57.      */
  58.     private $type
  59.     /**
  60.      * @var string
  61.      *
  62.      * @ORM\Column(name="value", type="decimal", precision=14, scale=2, nullable=false)
  63.      */
  64.     private $value;
  65.     
  66.     /**
  67.      * @var string
  68.      *
  69.      * @ORM\Column(name="gift_for", type="string", length=255, nullable=true)
  70.      */
  71.     private $giftFor;
  72.     /**
  73.      * @var string
  74.      *
  75.      * @ORM\Column(name="gift_from", type="string", length=255, nullable=true)
  76.      */
  77.     private $giftFrom;
  78.     /**
  79.      * @var string
  80.      *
  81.      * @ORM\Column(name="gift_message", type="string", length=4096, nullable=true)
  82.      */
  83.     private $giftMessage;
  84.     /**
  85.      * @var string
  86.      *
  87.      * @ORM\Column(name="price", type="decimal", precision=14, scale=2, nullable=false)
  88.      */
  89.     private $price;
  90.     /**
  91.      * @var int
  92.      *
  93.      * @ORM\Column(name="quantity", type="integer", nullable=false)
  94.      */
  95.     private $quantity;
  96.     /**
  97.      * @var string
  98.      *
  99.      * @ORM\Column(name="total_price", type="decimal", precision=14, scale=2, nullable=false)
  100.      */
  101.     private $totalPrice;
  102.     
  103.     /**
  104.      * @var \App\Admin\Modules\Voucher\Entity\VoucherPackageVoucher
  105.      *
  106.      * @ORM\ManyToMany(targetEntity="App\Admin\Modules\Voucher\Entity\VoucherPackageVoucher", inversedBy="orderVoucher")
  107.      * @ORM\JoinTable(name="voucher_order_voucher_package_voucher",
  108.      *      joinColumns={@ORM\JoinColumn(name="id_voucher_order_voucher", referencedColumnName="id", onDelete="CASCADE")},
  109.      *      inverseJoinColumns={@ORM\JoinColumn(name="id_vouhcer_package_voucher", referencedColumnName="id", onDelete="CASCADE")}
  110.      *    )
  111.      **/
  112.     private $packageVouchers;
  113.     public function __construct()
  114.     {
  115.         $this->packageVouchers = new ArrayCollection();
  116.     }    
  117.     public function getId(): ?string
  118.     {
  119.         return $this->id;
  120.     }
  121.     public function getType(): ?int
  122.     {
  123.         return $this->type;
  124.     }
  125.     public function setType(int $type): self
  126.     {
  127.         $this->type $type;
  128.         return $this;
  129.     }
  130.     public function getName(): ?string
  131.     {
  132.         return $this->name;
  133.     }
  134.     public function setName(?string $name): self
  135.     {
  136.         $this->name $name;
  137.         return $this;
  138.     }
  139.     public function getValue(): ?string
  140.     {
  141.         return $this->value;
  142.     }
  143.     public function setValue(string $value): self
  144.     {
  145.         $this->value $value;
  146.         return $this;
  147.     }
  148.     public function getPrice(): ?string
  149.     {
  150.         return $this->price;
  151.     }
  152.     public function setPrice(string $price): self
  153.     {
  154.         $this->price $price;
  155.         return $this;
  156.     }
  157.     public function getOrder(): ?VoucherOrder
  158.     {
  159.         return $this->order;
  160.     }
  161.     public function setOrder(?VoucherOrder $order): self
  162.     {
  163.         $this->order $order;
  164.         return $this;
  165.     }
  166.     public function getQuantity(): ?int
  167.     {
  168.         return $this->quantity;
  169.     }
  170.     public function setQuantity(int $quantity): self
  171.     {
  172.         $this->quantity $quantity;
  173.         return $this;
  174.     }
  175.     public function getTotalPrice(): ?string
  176.     {
  177.         return $this->totalPrice;
  178.     }
  179.     public function setTotalPrice(string $totalPrice): self
  180.     {
  181.         $this->totalPrice $totalPrice;
  182.         return $this;
  183.     }
  184.     public function getPackage(): ?VoucherPackage
  185.     {
  186.         return $this->package;
  187.     }
  188.     public function setPackage(?VoucherPackage $package): self
  189.     {
  190.         $this->package $package;
  191.         return $this;
  192.     }
  193.     /**
  194.      * @return Collection<int, VoucherPackageVoucher>
  195.      */
  196.     public function getPackageVouchers(): Collection
  197.     {
  198.         return $this->packageVouchers;
  199.     }
  200.     public function addPackageVoucher(VoucherPackageVoucher $packageVoucher): self
  201.     {
  202.         if (!$this->packageVouchers->contains($packageVoucher)) {
  203.             $this->packageVouchers->add($packageVoucher);
  204.         }
  205.         return $this;
  206.     }
  207.     public function removePackageVoucher(VoucherPackageVoucher $packageVoucher): self
  208.     {
  209.         $this->packageVouchers->removeElement($packageVoucher);
  210.         return $this;
  211.     }
  212.     public function getGiftFrom(): ?string
  213.     {
  214.         return $this->giftFrom;
  215.     }
  216.     public function setGiftFrom(?string $giftFrom): self
  217.     {
  218.         $this->giftFrom $giftFrom;
  219.         return $this;
  220.     }
  221.     public function getGiftFor(): ?string
  222.     {
  223.         return $this->giftFor;
  224.     }
  225.     public function setGiftFor(?string $giftFor): self
  226.     {
  227.         $this->giftFor $giftFor;
  228.         return $this;
  229.     }
  230.     public function getGiftMessage(): ?string
  231.     {
  232.         return $this->giftMessage;
  233.     }
  234.     public function setGiftMessage(?string $giftMessage): self
  235.     {
  236.         $this->giftMessage $giftMessage;
  237.         return $this;
  238.     }
  239. }