src/Entity/GiftCertificate.php line 10

Open in your IDE?
  1. <?php
  2. namespace Slivki\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Slivki\Entity\GiftCertificate\GiftCertificateGroup;
  6. use Slivki\Entity\Media\GiftCertificateMedia;
  7. class GiftCertificate extends Entity
  8. {
  9.     public const PREVIEW_PATH '/znijki-media/crt-preview/';
  10.     protected $active;
  11.     protected $name;
  12.     protected $priceRegular;
  13.     protected $priceOffer;
  14.     protected $discountPercent;
  15.     protected $description;
  16.     protected $offer;
  17.     protected Collection $media;
  18.     protected $position;
  19.     protected $codesPerItem;
  20.     protected $hidden;
  21.     private bool $buyOnlyCode;
  22.     private bool $special123;
  23.     protected $geoLocations;
  24.     protected $tags;
  25.     protected $activeDays;
  26.     protected $pricePartnerPurchase;
  27.     protected $giftCertificateCodePools;
  28.     protected $codeSuffix;
  29.     protected Collection $categories;
  30.     protected Collection $giftCategories;
  31.     protected Collection $groups;
  32.     private ?int $bundlePromoCount;
  33.     protected int $purchaseCount;
  34.     protected ?int $positionBeauty;
  35.     private ?int $multiUseCodePeriod;
  36.     private ?int $multiUseCodePerPeriod;
  37.     private bool $isSubscription;
  38.     private ?string $badgeLabel;
  39.     private ?string $badgeTextColor;
  40.     private ?string $badgeBgColor;
  41.     public function __construct()
  42.     {
  43.         $this->tags = new ArrayCollection();
  44.         $this->geoLocations = new ArrayCollection();
  45.         $this->giftCertificateCodePools = new ArrayCollection();
  46.         $this->categories = new ArrayCollection();
  47.         $this->giftCategories = new ArrayCollection();
  48.         $this->groups = new ArrayCollection();
  49.         $this->media = new ArrayCollection();
  50.         $this->buyOnlyCode false;
  51.         $this->purchaseCount 0;
  52.     }
  53.     public function isActive()
  54.     {
  55.         return $this->active;
  56.     }
  57.     public function setActive($active) {
  58.         $this->active $active;
  59.     }
  60.     public function getName() {
  61.         return $this->name;
  62.     }
  63.     public function setName($name) {
  64.         $this->name $name;
  65.     }
  66.     public function getPriceRegular() {
  67.         return $this->priceRegular;
  68.     }
  69.     public function setPriceRegular($priceRegular) {
  70.         $this->priceRegular $priceRegular;
  71.     }
  72.     public function getPriceOffer() {
  73.         return $this->priceOffer;
  74.     }
  75.     public function setPriceOffer($priceOffer) {
  76.         $this->priceOffer $priceOffer;
  77.     }
  78.     public function getDiscountPercent() {
  79.         return $this->discountPercent;
  80.     }
  81.     public function setDiscountPercent($dicountPercent) {
  82.         $this->discountPercent $dicountPercent;
  83.     }
  84.     public function getDescription() {
  85.         return $this->description;
  86.     }
  87.     public function setDescription($description) {
  88.         $this->description $description;
  89.     }
  90.     /**
  91.      * @return Offer
  92.      */
  93.     public function getOffer()
  94.     {
  95.         return $this->offer;
  96.     }
  97.     public function setOffer(Offer $offer) {
  98.         $this->offer $offer;
  99.     }
  100.     public function getMedia(): ?GiftCertificateMedia
  101.     {
  102.         return $this->media->count() > $this->media->first() : null;
  103.     }
  104.     public function setMedia(GiftCertificateMedia $media): void
  105.     {
  106.         $media->setGiftCertificate($this);
  107.         $this->media = new ArrayCollection([$media]);
  108.     }
  109.     public function getCurrentPrice() {
  110.         return $this->priceOffer;
  111.     }
  112.     public function getPrice() {
  113.         return $this->priceRegular;
  114.     }
  115.     public function getPriceByTime() {
  116.         return '[[0,0,"' $this->priceOffer '"]]';
  117.     }
  118.     public function getPosition() {
  119.         return $this->position;
  120.     }
  121.     public function setPosition($position) {
  122.         $this->position $position;
  123.     }
  124.     public function getCodesPerItem() {
  125.         return $this->codesPerItem;
  126.     }
  127.     public function setCodesPerItem($codesPerItem) {
  128.         $this->codesPerItem $codesPerItem;
  129.     }
  130.     public function isHidden() {
  131.         return $this->hidden;
  132.     }
  133.     public function setHidden($hidden) {
  134.         $this->hidden $hidden;
  135.     }
  136.     public function isBuyOnlyCode(): bool
  137.     {
  138.         return $this->buyOnlyCode;
  139.     }
  140.     public function setBuyOnlyCode(bool $buyOnlyCode): void
  141.     {
  142.         $this->buyOnlyCode $buyOnlyCode;
  143.     }
  144.     public function isSpecial123(): bool
  145.     {
  146.         return $this->special123;
  147.     }
  148.     public function setSpecial123(bool $special123): void
  149.     {
  150.         $this->special123 $special123;
  151.     }
  152.     public function getGeoLocations() {
  153.         return $this->geoLocations;
  154.     }
  155.     public function addGeoLocation(GeoLocation $geoLocation) {
  156.         if (!$this->geoLocations->contains($geoLocation)) {
  157.             $this->geoLocations->add($geoLocation);
  158.         }
  159.     }
  160.     public function removeGeoLocation(GeoLocation $geoLocation) {
  161.         $this->geoLocations->removeElement($geoLocation);
  162.     }
  163.     /**
  164.      * @return ArrayCollection
  165.      */
  166.     public function getTags() {
  167.         return $this->tags;
  168.     }
  169.     public function addTag(GiftCertificateTag $tag) {
  170.         if (!$this->tags->contains($tag)) {
  171.             $tag->addGiftCertificates($this);
  172.             $this->tags->add($tag);
  173.         }
  174.     }
  175.     public function deleteTag(GiftCertificateTag $tag) {
  176.         $this->tags->removeElement($tag);
  177.     }
  178.     public function getActiveDays() {
  179.         return $this->activeDays;
  180.     }
  181.     public function setActiveDays($activeDays) {
  182.         $this->activeDays $activeDays;
  183.     }
  184.     public function getPricePartnerPurchase() {
  185.         return $this->pricePartnerPurchase;
  186.     }
  187.     public function setPricePartnerPurchase($pricePartnerPurchase) {
  188.         $this->pricePartnerPurchase $pricePartnerPurchase;
  189.     }
  190.     public function getGiftCertificateCodePools() {
  191.         return $this->giftCertificateCodePools;
  192.     }
  193.     public function setGiftCertificateCodePools(ArrayCollection $giftCertificateCodePools) {
  194.         $this->giftCertificateCodePools $giftCertificateCodePools;
  195.     }
  196.     /** @return bool|GiftCertificateCodePool */
  197.     public function getLastActiveCodePool() {
  198.         /** @var \Slivki\Entity\GiftCertificateCodePool $giftCertificateCodePool */
  199.         foreach ($this->giftCertificateCodePools as $giftCertificateCodePool) {
  200.             if ($giftCertificateCodePool->isActive()) {
  201.                 return $giftCertificateCodePool;
  202.             }
  203.         }
  204.         return false;
  205.     }
  206.     public function getCodeSuffix() {
  207.         return $this->codeSuffix;
  208.     }
  209.     public function setCodeSuffix($codeSuffix) {
  210.         $this->codeSuffix $codeSuffix;
  211.     }
  212.     public function getCategories(): Collection
  213.     {
  214.         return $this->categories;
  215.     }
  216.     public function addCategory(GiftCertificateCategory $category): void
  217.     {
  218.         if (!$this->categories->contains($category)) {
  219.             $this->categories->add($category);
  220.         }
  221.     }
  222.     public function removeCategory(GiftCertificateCategory $category):void
  223.     {
  224.         $this->categories->removeElement($category);
  225.     }
  226.     public function getGiftCategories(): Collection
  227.     {
  228.         return $this->giftCategories;
  229.     }
  230.     public function addGiftCategory(GiftCertificateGiftCategory $category): void
  231.     {
  232.         if (!$this->giftCategories->contains($category)) {
  233.             $this->giftCategories->add($category);
  234.         }
  235.     }
  236.     public function removeGiftCategory(GiftCertificateGiftCategory $category):void
  237.     {
  238.         $this->giftCategories->removeElement($category);
  239.     }
  240.     /**
  241.      * @return Collection<GiftCertificateGroup>
  242.      */
  243.     public function getGroups(): Collection
  244.     {
  245.         return $this->groups;
  246.     }
  247.     public function addGroup(GiftCertificateGroup $group): void
  248.     {
  249.         if (!$this->groups->contains($group)) {
  250.             $this->groups->add($group);
  251.         }
  252.     }
  253.     public function removeGroup(GiftCertificateGroup $group):void
  254.     {
  255.         $this->groups->removeElement($group);
  256.     }
  257.     public function getBundlePromoCount(): ?int
  258.     {
  259.         return $this->bundlePromoCount;
  260.     }
  261.     public function setBundlePromoCount(?int $bundlePromoCount): void
  262.     {
  263.         $this->bundlePromoCount $bundlePromoCount;
  264.     }
  265.     public function getPurchaseCount(): int
  266.     {
  267.         return $this->purchaseCount;
  268.     }
  269.     public function getPositionBeauty(): ?int
  270.     {
  271.         return $this->positionBeauty;
  272.     }
  273.     public function editPositionBeauty(int $positionBeauty): void
  274.     {
  275.         $this->positionBeauty $positionBeauty;
  276.     }
  277.     public function getMultiUseCodePeriod(): ?int
  278.     {
  279.         return $this->multiUseCodePeriod;
  280.     }
  281.     public function setMultiUseCodePeriod(?int $multiUseCodePeriod): void
  282.     {
  283.         $this->multiUseCodePeriod $multiUseCodePeriod;
  284.     }
  285.     public function getMultiUseCodePerPeriod(): ?int
  286.     {
  287.         return $this->multiUseCodePerPeriod;
  288.     }
  289.     public function setMultiUseCodePerPeriod(?int $multiUseCodePerPeriod): void
  290.     {
  291.         $this->multiUseCodePerPeriod $multiUseCodePerPeriod;
  292.     }
  293.     public function isMultiUseCode(): bool
  294.     {
  295.         return $this->multiUseCodePeriod && $this->multiUseCodePerPeriod 0;
  296.     }
  297.     public function isSubscription(): bool
  298.     {
  299.         return $this->isSubscription;
  300.     }
  301.     public function setIsSubscription(bool $isSubscription): void
  302.     {
  303.         $this->isSubscription $isSubscription;
  304.     }
  305.     public function getBadgeLabel(): ?string
  306.     {
  307.         return $this->badgeLabel;
  308.     }
  309.     public function setBadgeLabel(?string $badgeLabel): void
  310.     {
  311.         $this->badgeLabel $badgeLabel;
  312.     }
  313.     public function getBadgeTextColor(): ?string
  314.     {
  315.         return $this->badgeTextColor;
  316.     }
  317.     public function setBadgeTextColor(?string $badgeTextColor): void
  318.     {
  319.         $this->badgeTextColor $badgeTextColor;
  320.     }
  321.     public function getBadgeBgColor(): ?string
  322.     {
  323.         return $this->badgeBgColor;
  324.     }
  325.     public function setBadgeBgColor(?string $badgeBgColor): void
  326.     {
  327.         $this->badgeBgColor $badgeBgColor;
  328.     }
  329. }