<?php
namespace App\Entity\Gos;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* ClientType
*
* @ORM\Table()
* @ORM\Entity(repositoryClass="App\Repository\ClientTypeRepository")
* @ORM\HasLifecycleCallbacks
*/
class ClientType
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var bool
*
* @ORM\Column(name="isActive", type="boolean", nullable=true)
*/
private $isActive;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255)
*/
private $name;
/**
* @Gedmo\Slug(fields={"name"})
* @ORM\Column(unique=true)
*/
private $slug;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Gos\ProductVariant", mappedBy="clientType")
*/
private $productVariant;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Gos\Coupon", mappedBy="clientType")
*/
private $coupons;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Gos\ArchivedCoupon", mappedBy="clientType")
*/
private $archivedCoupons;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Gos\Address", mappedBy="clientType")
*/
private $address;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Gos\ProductVariantPack", mappedBy="clientTypes")
*/
private $productVariantPacks;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Gos\Term", mappedBy="clientTypes")
*/
private $terms;
/** @ORM\PrePersist() */
public function prePersist()
{
$this->createdAt = new \DateTime();
}
/** @ORM\PreUpdate() */
public function preUpdate()
{
$this->updatedAt = new \DateTime();
}
public function __toString()
{
return (string)$this->name;
}
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set isActive
*
* @param boolean $isActive
*
* @return ClientType
*/
public function setIsActive($isActive)
{
$this->isActive = $isActive;
return $this;
}
/**
* Get isActive
*
* @return bool
*/
public function getIsActive()
{
return $this->isActive;
}
/**
* Set name
*
* @param string $name
*
* @return ClientType
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Constructor
*/
public function __construct()
{
$this->productVariant = new \Doctrine\Common\Collections\ArrayCollection();
$this->address = new ArrayCollection();
$this->coupons = new ArrayCollection();
$this->productVariantPacks = new ArrayCollection();
$this->terms = new ArrayCollection();
}
/**
* Set slug
*
* @param string $slug
*
* @return ClientType
*/
public function setSlug($slug)
{
$this->slug = $slug;
return $this;
}
/**
* Get slug
*
* @return string
*/
public function getSlug()
{
return $this->slug;
}
/**
* Set createdAt
*
* @param \DateTime $createdAt
*
* @return ClientType
*/
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
/**
* Get createdAt
*
* @return \DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Set updatedAt
*
* @param \DateTime $updatedAt
*
* @return ClientType
*/
public function setUpdatedAt($updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* Get updatedAt
*
* @return \DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* Add productVariant
*
* @param \App\Entity\Gos\ProductVariant $productVariant
*
* @return ClientType
*/
public function addProductVariant(\App\Entity\Gos\ProductVariant $productVariant)
{
$this->productVariant[] = $productVariant;
return $this;
}
/**
* Remove productVariant
*
* @param \App\Entity\Gos\ProductVariant $productVariant
*/
public function removeProductVariant(\App\Entity\Gos\ProductVariant $productVariant)
{
$this->productVariant->removeElement($productVariant);
}
/**
* Get productVariant
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getProductVariant()
{
return $this->productVariant;
}
/**
* Add address
*
* @param \App\Entity\Gos\Address $address
*
* @return ClientType
*/
public function addAddress(\App\Entity\Gos\Address $address)
{
$this->address[] = $address;
return $this;
}
/**
* Remove address
*
* @param \App\Entity\Gos\Address $address
*/
public function removeAddress(\App\Entity\Gos\Address $address)
{
$this->address->removeElement($address);
}
/**
* Get address
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getAddress()
{
return $this->address;
}
/**
* @return Collection|Coupon[]
*/
public function getCoupons(): Collection
{
return $this->coupons;
}
public function addCoupon(Coupon $coupon): self
{
if (!$this->coupons->contains($coupon)) {
$this->coupons[] = $coupon;
$coupon->setClientType($this);
}
return $this;
}
public function removeCoupon(Coupon $coupon): self
{
if ($this->coupons->contains($coupon)) {
$this->coupons->removeElement($coupon);
// set the owning side to null (unless already changed)
if ($coupon->getClientType() === $this) {
$coupon->setClientType(null);
}
}
return $this;
}
/**
* @return Collection|ProductVariantPack[]
*/
public function getProductVariantPacks(): Collection
{
return $this->productVariantPacks;
}
public function addProductVariantPack(ProductVariantPack $productVariantPack): self
{
if (!$this->productVariantPacks->contains($productVariantPack)) {
$this->productVariantPacks[] = $productVariantPack;
$productVariantPack->addClientType($this);
}
return $this;
}
public function removeProductVariantPack(ProductVariantPack $productVariantPack): self
{
if ($this->productVariantPacks->contains($productVariantPack)) {
$this->productVariantPacks->removeElement($productVariantPack);
$productVariantPack->removeClientType($this);
}
return $this;
}
/**
* @return Collection|Term[]
*/
public function getTerms(): Collection
{
return $this->terms;
}
public function addTerm(Term $term): self
{
if (!$this->terms->contains($term)) {
$this->terms[] = $term;
$term->addClientType($this);
}
return $this;
}
public function removeTerm(Term $term): self
{
if ($this->terms->contains($term)) {
$this->terms->removeElement($term);
$term->removeClientType($this);
}
return $this;
}
public function isBusinessClient(): bool
{
return $this->slug === 'clienttype-business';
}
}