src/Entity/Gos/ClientType.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gos;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Gedmo\Mapping\Annotation as Gedmo;
  7. /**
  8.  * ClientType
  9.  *
  10.  * @ORM\Table()
  11.  * @ORM\Entity(repositoryClass="App\Repository\ClientTypeRepository")
  12.  * @ORM\HasLifecycleCallbacks
  13.  */
  14. class ClientType
  15. {
  16.     /**
  17.      * @var int
  18.      *
  19.      * @ORM\Column(name="id", type="integer")
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue(strategy="AUTO")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @var bool
  26.      *
  27.      * @ORM\Column(name="isActive", type="boolean", nullable=true)
  28.      */
  29.     private $isActive;
  30.     /**
  31.      * @var string
  32.      *
  33.      * @ORM\Column(name="name", type="string", length=255)
  34.      */
  35.     private $name;
  36.     /**
  37.      * @Gedmo\Slug(fields={"name"})
  38.      * @ORM\Column(unique=true)
  39.      */
  40.     private $slug;
  41.     /**
  42.      * @ORM\ManyToMany(targetEntity="App\Entity\Gos\ProductVariant", mappedBy="clientType")
  43.      */
  44.     private $productVariant;
  45.     /**
  46.      * @ORM\OneToMany(targetEntity="App\Entity\Gos\Coupon", mappedBy="clientType")
  47.      */
  48.     private $coupons;
  49.     /**
  50.      * @ORM\OneToMany(targetEntity="App\Entity\Gos\ArchivedCoupon", mappedBy="clientType")
  51.      */
  52.     private $archivedCoupons;
  53.     /**
  54.      * @ORM\OneToMany(targetEntity="App\Entity\Gos\Address", mappedBy="clientType")
  55.      */
  56.     private $address;
  57.     /**
  58.      * @ORM\Column(type="datetime")
  59.      */
  60.     private $createdAt;
  61.     /**
  62.      * @ORM\Column(type="datetime", nullable=true)
  63.      */
  64.     private $updatedAt;
  65.     /**
  66.      * @ORM\ManyToMany(targetEntity="App\Entity\Gos\ProductVariantPack", mappedBy="clientTypes")
  67.      */
  68.     private $productVariantPacks;
  69.     /**
  70.      * @ORM\ManyToMany(targetEntity="App\Entity\Gos\Term", mappedBy="clientTypes")
  71.      */
  72.     private $terms;
  73.     /** @ORM\PrePersist() */
  74.     public function prePersist()
  75.     {
  76.         $this->createdAt = new \DateTime();
  77.     }
  78.     /** @ORM\PreUpdate() */
  79.     public function preUpdate()
  80.     {
  81.         $this->updatedAt = new \DateTime();
  82.     }
  83.     public function __toString()
  84.     {
  85.         return (string)$this->name;
  86.     }
  87.     /**
  88.      * Get id
  89.      *
  90.      * @return int
  91.      */
  92.     public function getId()
  93.     {
  94.         return $this->id;
  95.     }
  96.     /**
  97.      * Set isActive
  98.      *
  99.      * @param boolean $isActive
  100.      *
  101.      * @return ClientType
  102.      */
  103.     public function setIsActive($isActive)
  104.     {
  105.         $this->isActive $isActive;
  106.         return $this;
  107.     }
  108.     /**
  109.      * Get isActive
  110.      *
  111.      * @return bool
  112.      */
  113.     public function getIsActive()
  114.     {
  115.         return $this->isActive;
  116.     }
  117.     /**
  118.      * Set name
  119.      *
  120.      * @param string $name
  121.      *
  122.      * @return ClientType
  123.      */
  124.     public function setName($name)
  125.     {
  126.         $this->name $name;
  127.         return $this;
  128.     }
  129.     /**
  130.      * Get name
  131.      *
  132.      * @return string
  133.      */
  134.     public function getName()
  135.     {
  136.         return $this->name;
  137.     }
  138.     /**
  139.      * Constructor
  140.      */
  141.     public function __construct()
  142.     {
  143.         $this->productVariant = new \Doctrine\Common\Collections\ArrayCollection();
  144.         $this->address = new ArrayCollection();
  145.         $this->coupons = new ArrayCollection();
  146.         $this->productVariantPacks = new ArrayCollection();
  147.         $this->terms = new ArrayCollection();
  148.     }
  149.     /**
  150.      * Set slug
  151.      *
  152.      * @param string $slug
  153.      *
  154.      * @return ClientType
  155.      */
  156.     public function setSlug($slug)
  157.     {
  158.         $this->slug $slug;
  159.         return $this;
  160.     }
  161.     /**
  162.      * Get slug
  163.      *
  164.      * @return string
  165.      */
  166.     public function getSlug()
  167.     {
  168.         return $this->slug;
  169.     }
  170.     /**
  171.      * Set createdAt
  172.      *
  173.      * @param \DateTime $createdAt
  174.      *
  175.      * @return ClientType
  176.      */
  177.     public function setCreatedAt($createdAt)
  178.     {
  179.         $this->createdAt $createdAt;
  180.         return $this;
  181.     }
  182.     /**
  183.      * Get createdAt
  184.      *
  185.      * @return \DateTime
  186.      */
  187.     public function getCreatedAt()
  188.     {
  189.         return $this->createdAt;
  190.     }
  191.     /**
  192.      * Set updatedAt
  193.      *
  194.      * @param \DateTime $updatedAt
  195.      *
  196.      * @return ClientType
  197.      */
  198.     public function setUpdatedAt($updatedAt)
  199.     {
  200.         $this->updatedAt $updatedAt;
  201.         return $this;
  202.     }
  203.     /**
  204.      * Get updatedAt
  205.      *
  206.      * @return \DateTime
  207.      */
  208.     public function getUpdatedAt()
  209.     {
  210.         return $this->updatedAt;
  211.     }
  212.     /**
  213.      * Add productVariant
  214.      *
  215.      * @param \App\Entity\Gos\ProductVariant $productVariant
  216.      *
  217.      * @return ClientType
  218.      */
  219.     public function addProductVariant(\App\Entity\Gos\ProductVariant $productVariant)
  220.     {
  221.         $this->productVariant[] = $productVariant;
  222.         return $this;
  223.     }
  224.     /**
  225.      * Remove productVariant
  226.      *
  227.      * @param \App\Entity\Gos\ProductVariant $productVariant
  228.      */
  229.     public function removeProductVariant(\App\Entity\Gos\ProductVariant $productVariant)
  230.     {
  231.         $this->productVariant->removeElement($productVariant);
  232.     }
  233.     /**
  234.      * Get productVariant
  235.      *
  236.      * @return \Doctrine\Common\Collections\Collection
  237.      */
  238.     public function getProductVariant()
  239.     {
  240.         return $this->productVariant;
  241.     }
  242.     /**
  243.      * Add address
  244.      *
  245.      * @param \App\Entity\Gos\Address $address
  246.      *
  247.      * @return ClientType
  248.      */
  249.     public function addAddress(\App\Entity\Gos\Address $address)
  250.     {
  251.         $this->address[] = $address;
  252.         return $this;
  253.     }
  254.     /**
  255.      * Remove address
  256.      *
  257.      * @param \App\Entity\Gos\Address $address
  258.      */
  259.     public function removeAddress(\App\Entity\Gos\Address $address)
  260.     {
  261.         $this->address->removeElement($address);
  262.     }
  263.     /**
  264.      * Get address
  265.      *
  266.      * @return \Doctrine\Common\Collections\Collection
  267.      */
  268.     public function getAddress()
  269.     {
  270.         return $this->address;
  271.     }
  272.     /**
  273.      * @return Collection|Coupon[]
  274.      */
  275.     public function getCoupons(): Collection
  276.     {
  277.         return $this->coupons;
  278.     }
  279.     public function addCoupon(Coupon $coupon): self
  280.     {
  281.         if (!$this->coupons->contains($coupon)) {
  282.             $this->coupons[] = $coupon;
  283.             $coupon->setClientType($this);
  284.         }
  285.         return $this;
  286.     }
  287.     public function removeCoupon(Coupon $coupon): self
  288.     {
  289.         if ($this->coupons->contains($coupon)) {
  290.             $this->coupons->removeElement($coupon);
  291.             // set the owning side to null (unless already changed)
  292.             if ($coupon->getClientType() === $this) {
  293.                 $coupon->setClientType(null);
  294.             }
  295.         }
  296.         return $this;
  297.     }
  298.     /**
  299.      * @return Collection|ProductVariantPack[]
  300.      */
  301.     public function getProductVariantPacks(): Collection
  302.     {
  303.         return $this->productVariantPacks;
  304.     }
  305.     public function addProductVariantPack(ProductVariantPack $productVariantPack): self
  306.     {
  307.         if (!$this->productVariantPacks->contains($productVariantPack)) {
  308.             $this->productVariantPacks[] = $productVariantPack;
  309.             $productVariantPack->addClientType($this);
  310.         }
  311.         return $this;
  312.     }
  313.     public function removeProductVariantPack(ProductVariantPack $productVariantPack): self
  314.     {
  315.         if ($this->productVariantPacks->contains($productVariantPack)) {
  316.             $this->productVariantPacks->removeElement($productVariantPack);
  317.             $productVariantPack->removeClientType($this);
  318.         }
  319.         return $this;
  320.     }
  321.     /**
  322.      * @return Collection|Term[]
  323.      */
  324.     public function getTerms(): Collection
  325.     {
  326.         return $this->terms;
  327.     }
  328.     public function addTerm(Term $term): self
  329.     {
  330.         if (!$this->terms->contains($term)) {
  331.             $this->terms[] = $term;
  332.             $term->addClientType($this);
  333.         }
  334.         return $this;
  335.     }
  336.     public function removeTerm(Term $term): self
  337.     {
  338.         if ($this->terms->contains($term)) {
  339.             $this->terms->removeElement($term);
  340.             $term->removeClientType($this);
  341.         }
  342.         return $this;
  343.     }
  344.     public function isBusinessClient(): bool
  345.     {
  346.         return $this->slug === 'clienttype-business';
  347.     }
  348. }