src/Entity/Product.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Futures\Feature;
  4. use App\Entity\Futures\TradeMarket;
  5. use App\Repository\ProductRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. /**
  10.  * @ORM\Table(name="app_product", uniqueConstraints={
  11.  *      @ORM\UniqueConstraint(name="unique_product", columns={"type", "name"})
  12.  * })
  13.  * @ORM\Entity(repositoryClass=ProductRepository::class)
  14.  */
  15. class Product
  16. {
  17.     // Produits Futures
  18.     public const SILVER_KEY 'silver';
  19.     public const SILVER_MIRROR_KEY 'silver_mirror';
  20.     public const SILVER_FULL_KEY 'silver_full';
  21.     public const GOLD_KEY 'gold';
  22.     public const GOLD_MIRROR_KEY 'gold_mirror';
  23.     public const GOLD_PRO_KEY 'gold_pro';
  24.     public const GOLD_FULL_KEY 'gold_full';
  25.     public const PLATINIUM_KEY 'platinium';
  26.     public const PREMIUM_KEY 'premium';
  27.     public const NO_PACK 'no_pack';
  28.     public const LINK_SUBSCRIPTION "link_subscription";
  29.     // Le premium full permet de conditionner l'affichage des services mirrors
  30.     public const PREMIUM_FULL_KEY 'premium_full';
  31.     public const AMBASSADOR_KEY 'ambassador';
  32.     // Produits Luume
  33.     public const PRODUCT_CLEAAN_ELIXIR_KEY "cleaan-elixir";
  34.     public const PRODUCT_PUURE_SHAPE_KEY "puure-shape";
  35.     public const PRODUCT_DRAAIN_TEA_KEY "draain-tea";
  36.     public const PRODUCT_MIND_FOCUUS_KEY "mind-focuus";
  37.     public const PRODUCT_VITA_BOOST_KEY "vita-boost";
  38.     public const PRODUCT_RELAAX_ME_KEY "relaax-me";
  39.     public const PRODUCT_NEEO_SLIM_KEY "neeo-slim";
  40.     public const PRODUCT_KONJAA_CONTROL_KEY "konjaa-control";
  41.     public const PRODUCT_PUURE_BURN_KEY "puure-burn";
  42.     public const PRODUCT_KERA_CAARE_KEY "kera-caare";
  43.     public const PRODUCT_BIOTI_BOOST_KEY "bioti-boost";
  44.     public const PRODUCT_COLLA_BLOOM_KEY "colla-bloom";
  45.     public const PRODUCT_FLEXIA_KEY "flexia";
  46.     public const PRODUCT_SILICIA_KEY "silicia";
  47.     public const PRODUCT_PULSIA_KEY "pulsia";
  48.     public const PRODUCT_DERMA_GLOW_KEY "derma-glow";
  49.     public const PRODUCT_GLASS_GLOW_KEY "glass-glow";
  50.     public const PRODUCT_VITALIUUM_KEY "vitaliuum";
  51.     public const PACK_PERFORMANCE "performance";
  52.     public const PACK_DETOX "detox";
  53.     public const PACK_SLIMFIT "slimfit";
  54.     public const PACK_HAIRFUSION "hairfusion";
  55.     public const PACK_COLLAGENCARE "collagencare";
  56.     public const PACK_COLLAGENBEAUTY "collagenbeauty";
  57.     public const PROGRAM_DETOX "detox-program";
  58.     public const PROGRAM_PERFORMANCE "performance-program";
  59.     public const PROGRAM_SLIMFIT "slimfit-program";
  60.     public const PROGRAM_HAIRFUSION "hairfusion-program";
  61.     public const PROGRAM_SLIMGOLD "slimgold-program";
  62.     public const PROGRAM_DECOUVERTE "decouverte-program";
  63.     public const FORMATION_PACKAGE_DIGITAL_ECOM "package-digital-ecom";
  64.     public const FORMATION_THEME_DIGITAL "digital";
  65.     public const FORMATION_THEME_ECOM "ecom";
  66.     public const FORMATION_THEME_FINANCE "finance";
  67.     public const FORMATION_BOURSE "bourse";
  68.     public const FORMATION_CRYPTO "crypto";
  69.     public const FORMATION_TRADING "trading";
  70.     public const NO_FORMATION "no-formation";
  71.     public const FORMATION_TRACKING_COOKIE_NAME "futures_learn_choice";
  72.     // On met une durée de formation à -1 pour représenter l'infini
  73.     public const FORMATION_DURATION 1;
  74.     public const LUUME_PRODUCT_NAMES = [
  75.         self::PRODUCT_CLEAAN_ELIXIR_KEY,
  76.         self::PRODUCT_PUURE_SHAPE_KEY,
  77.         self::PRODUCT_DRAAIN_TEA_KEY,
  78.         self::PRODUCT_MIND_FOCUUS_KEY,
  79.         self::PRODUCT_VITA_BOOST_KEY,
  80.         self::PRODUCT_RELAAX_ME_KEY,
  81.         self::PRODUCT_NEEO_SLIM_KEY,
  82.         self::PRODUCT_KONJAA_CONTROL_KEY,
  83.         self::PRODUCT_PUURE_BURN_KEY,
  84.         self::PRODUCT_KERA_CAARE_KEY,
  85.         self::PRODUCT_BIOTI_BOOST_KEY,
  86.         self::PRODUCT_COLLA_BLOOM_KEY
  87.     ];
  88.     public const LUUME_PACKS = [
  89.         self::PACK_PERFORMANCE,
  90.         self::PACK_DETOX,
  91.         self::PACK_SLIMFIT,
  92.         self::PACK_HAIRFUSION
  93.     ];
  94.     public const LUUME_FORM_CHOICE_PACKS = [
  95.         self::PACK_PERFORMANCE => "Performance",
  96.         self::PACK_DETOX => "Detox",
  97.         self::PACK_SLIMFIT => "Slimfit",
  98.         self::PACK_HAIRFUSION => "Hairfusion"
  99.     ];
  100.     public const FUTURES_PACK_IKIGAI_PLUS_CHOICE = [
  101.         self::PREMIUM_KEY => "Premium",
  102.     ];
  103.     public const FUTURES_PACK_IKIGAI_CHOICE = [
  104.         self::GOLD_FULL_KEY => "Gold Full",
  105.         self::SILVER_FULL_KEY => "Silver Full",
  106.     ];
  107.     // Produits Mybiz
  108.     public const IKIGAI_KEY "ikigai";
  109.     public const IKIGAI_PLUS_KEY "ikigai-plus";
  110.     public const PRODUCT_TYPE_LICENSE "license";
  111.     public const PRODUCT_TYPE_PACK "pack"// Représente les produits de type pack (sous forme d'abonnement)
  112.     public const PRODUCT_TYPE_PROGRAM "program"// Représente (sur Luume) un ensemble de pack regroupé sous le même EAN
  113.     public const PRODUCT_TYPE_PRODUCT "product"// Représente les produits de type produit (sous forme de produit à l'unité)
  114.     public const PRODUCT_TYPE_PREDICTION "prediction"// Représente les produits de type prediction acheté indépendamment des souscriptions
  115.     public const PRODUCT_TYPE_FORMATION "formation"// Représente les académies de formation que l'on peut vendre (à commencer par digital et ecom)
  116.     public const PRODUCT_TYPE_LINK "link"// Représente la souscription Link c'est assez différent des autres cas
  117.     public const PRODUCT_PACK_STARTER "starter";
  118.     /**
  119.      * @ORM\Id
  120.      * @ORM\GeneratedValue
  121.      * @ORM\Column(type="integer")
  122.      */
  123.     private ?int $id null;
  124.     /**
  125.      * @ORM\Column(type="string", length=25)
  126.      */
  127.     private ?string $type null;
  128.     /**
  129.      * @ORM\Column(type="string", length=25)
  130.      */
  131.     private ?string $name null;
  132.     /**
  133.      * @ORM\Column(type="string", length=255, unique=true)
  134.      */
  135.     private ?string $sku null;
  136.     /**
  137.      * @ORM\Column(type="boolean")
  138.      */
  139.     private bool $isEnabled true;
  140.     /**
  141.      * @ORM\Column(type="boolean")
  142.      */
  143.     private bool $isSubscibable true;
  144.     /**
  145.      * @ORM\Column(type="boolean")
  146.      */
  147.     private bool $isIkigaiPack false;
  148.     /**
  149.      * Est-ce qu'on affiche ce produit à l'inscription sur Futures (prévu pour la transition des offres commerciales sur Futures)
  150.      * @ORM\Column(type="boolean")
  151.      */
  152.     private bool $isPrintable false;
  153.     /**
  154.      * @ORM\ManyToMany(targetEntity="App\Entity\Futures\Feature", inversedBy="products")
  155.      * @ORM\JoinTable(name="app_product_features")
  156.      */
  157.     private ?Collection $features;
  158.     /**
  159.      * @ORM\OneToMany(targetEntity=Member::class, mappedBy="pack")
  160.      */
  161.     private ?Collection $members;
  162.     /**
  163.      * @ORM\Column(type="string", length=255, nullable=true)
  164.      */
  165.     private ?string $marketingName null;
  166.     /**
  167.      * @ORM\Column(type="string", length=255, nullable=true)
  168.      */
  169.     private ?string $imagePath null;
  170.     /**
  171.      * @ORM\Column(type="string", length=255, nullable=true)
  172.      */
  173.     private ?string $color null;
  174.     /**
  175.      * @ORM\OneToMany(targetEntity=Subscription::class, mappedBy="product", orphanRemoval=true)
  176.      */
  177.     private Collection $subscriptions;
  178.     /**
  179.      * @ORM\ManyToOne(targetEntity=Space::class, inversedBy="products")
  180.      * @ORM\JoinColumn(nullable=false)
  181.      */
  182.     private ?Space $space null;
  183.     /**
  184.      * @ORM\OneToMany(targetEntity=ProductPrice::class, mappedBy="product")
  185.      */
  186.     private ?Collection $productPrices;
  187.     /**
  188.      * @ORM\OneToMany(targetEntity=ProductPoint::class, mappedBy="product")
  189.      */
  190.     private ?Collection $productPoints;
  191.     /**
  192.      * @ORM\OneToMany(targetEntity=ProductPrediction::class, mappedBy="product")
  193.      */
  194.     private ?Collection $productPredictions;
  195.     /**
  196.      * @ORM\ManyToMany(targetEntity=TradeMarket::class, mappedBy="products")
  197.      */
  198.     private ?Collection $tradeMarkets;
  199.     /**
  200.      * @ORM\Column(type="json", nullable=true)
  201.      */
  202.     private ?array $context = [];
  203.     public function __construct()
  204.     {
  205.         $this->features = new ArrayCollection();
  206.         $this->members = new ArrayCollection();
  207.         $this->subscriptions = new ArrayCollection();
  208.         $this->productPrices = new ArrayCollection();
  209.         $this->productPoints = new ArrayCollection();
  210.         $this->productPredictions = new ArrayCollection();
  211.         $this->tradeMarkets = new ArrayCollection();
  212.     }
  213.     /**
  214.      * @return int|null
  215.      */
  216.     public function getId(): ?int
  217.     {
  218.         return $this->id;
  219.     }
  220.     /**
  221.      * @return string|null
  222.      */
  223.     public function getType(): ?string
  224.     {
  225.         return $this->type;
  226.     }
  227.     /**
  228.      * @param string $type
  229.      * @return $this
  230.      */
  231.     public function setType(string $type): self
  232.     {
  233.         $this->type $type;
  234.         return $this;
  235.     }
  236.     /**
  237.      * @return string|null
  238.      */
  239.     public function getName(): ?string
  240.     {
  241.         return $this->name;
  242.     }
  243.     /**
  244.      * @param string $name
  245.      * @return $this
  246.      */
  247.     public function setName(string $name): self
  248.     {
  249.         $this->name $name;
  250.         return $this;
  251.     }
  252.     /**
  253.      * @return string|null
  254.      */
  255.     public function getSku(): ?string
  256.     {
  257.         return $this->sku;
  258.     }
  259.     /**
  260.      * @param string|null $sku
  261.      */
  262.     public function setSku(?string $sku): void
  263.     {
  264.         $this->sku $sku;
  265.     }
  266.     /**
  267.      * @return bool|null
  268.      */
  269.     public function isEnabled(): ?bool
  270.     {
  271.         return $this->isEnabled;
  272.     }
  273.     /**
  274.      * @param bool $isEnabled
  275.      * @return $this
  276.      */
  277.     public function setIsEnabled(bool $isEnabled): self
  278.     {
  279.         $this->isEnabled $isEnabled;
  280.         return $this;
  281.     }
  282.     /**
  283.      * @return bool
  284.      */
  285.     public function isSubscibable(): bool
  286.     {
  287.         return $this->isSubscibable;
  288.     }
  289.     /**
  290.      * @param bool $isSubscibable
  291.      */
  292.     public function setIsSubscibable(bool $isSubscibable): void
  293.     {
  294.         $this->isSubscibable $isSubscibable;
  295.     }
  296.     /**
  297.      * @return bool
  298.      */
  299.     public function isIkigaiPack(): bool
  300.     {
  301.         return $this->isIkigaiPack;
  302.     }
  303.     /**
  304.      * @param bool $isIkigaiPack
  305.      */
  306.     public function setIsIkigaiPack(bool $isIkigaiPack): void
  307.     {
  308.         $this->isIkigaiPack $isIkigaiPack;
  309.     }
  310.     /**
  311.      * @return bool
  312.      */
  313.     public function isPrintable(): bool
  314.     {
  315.         return $this->isPrintable;
  316.     }
  317.     /**
  318.      * @param bool $isPrintable
  319.      */
  320.     public function setIsPrintable(bool $isPrintable): void
  321.     {
  322.         $this->isPrintable $isPrintable;
  323.     }
  324.     /**
  325.      * @return Collection
  326.      */
  327.     public function getFeatures(): Collection
  328.     {
  329.         return $this->features;
  330.     }
  331.     /**
  332.      * @param Feature $feature
  333.      * @return bool
  334.      */
  335.     public function hasFeature(Feature $feature): bool
  336.     {
  337.         return $this->features->contains($feature);
  338.     }
  339.     /**
  340.      * @param Feature $feature
  341.      * @return $this
  342.      */
  343.     public function addFeature(Feature $feature): self
  344.     {
  345.         if ($this->features->contains($feature)) {
  346.             return $this;
  347.         }
  348.         $this->features->add($feature);
  349.         return $this;
  350.     }
  351.     /**
  352.      * @param Feature $feature
  353.      * @return $this
  354.      */
  355.     public function removeFeature(Feature $feature): self
  356.     {
  357.         if (!$this->features->contains($feature)) {
  358.             return $this;
  359.         }
  360.         $this->features->remove($feature);
  361.         return $this;
  362.     }
  363.     /**
  364.      * @return Collection|null
  365.      */
  366.     public function getMembers(): ?Collection
  367.     {
  368.         return $this->members;
  369.     }
  370.     /**
  371.      * @param Member $member
  372.      * @return $this
  373.      */
  374.     public function addMember(Member $member): self
  375.     {
  376.         if ($this->members->contains($member)) {
  377.             return $this;
  378.         }
  379.         $this->members->add($member);
  380.         return $this;
  381.     }
  382.     /**
  383.      * @param Member $member
  384.      * @return $this
  385.      */
  386.     public function removeMember(Member $member): self
  387.     {
  388.         if (!$this->members->contains($member)) {
  389.             return $this;
  390.         }
  391.         $this->members->remove($member);
  392.         return $this;
  393.     }
  394.     /**
  395.      * @return string
  396.      */
  397.     public function __toString(): string
  398.     {
  399.         return $this->getName();
  400.     }
  401.     /**
  402.      * @return string|null
  403.      */
  404.     public function getMarketingName(): ?string
  405.     {
  406.         return $this->marketingName;
  407.     }
  408.     /**
  409.      * @param string|null $marketingName
  410.      * @return $this
  411.      */
  412.     public function setMarketingName(?string $marketingName): self
  413.     {
  414.         $this->marketingName $marketingName;
  415.         return $this;
  416.     }
  417.     /**
  418.      * @return string|null
  419.      */
  420.     public function getImagePath(): ?string
  421.     {
  422.         return $this->imagePath;
  423.     }
  424.     /**
  425.      * @param string|null $imagePath
  426.      * @return $this
  427.      */
  428.     public function setImagePath(?string $imagePath): self
  429.     {
  430.         $this->imagePath $imagePath;
  431.         return $this;
  432.     }
  433.     /**
  434.      * @return string|null
  435.      */
  436.     public function getColor(): ?string
  437.     {
  438.         return $this->color;
  439.     }
  440.     /**
  441.      * @param string|null $color
  442.      */
  443.     public function setColor(?string $color): void
  444.     {
  445.         $this->color $color;
  446.     }
  447.     /**
  448.      * @return Collection
  449.      */
  450.     public function getSubscriptions(): Collection
  451.     {
  452.         return $this->subscriptions;
  453.     }
  454.     /**
  455.      * @param Subscription $subscription
  456.      * @return $this
  457.      */
  458.     public function addSubscription(Subscription $subscription): self
  459.     {
  460.         if (!$this->subscriptions->contains($subscription)) {
  461.             $this->subscriptions->add($subscription);
  462.             $subscription->setProduct($this);
  463.         }
  464.         return $this;
  465.     }
  466.     /**
  467.      * @param Subscription $subscription
  468.      * @return $this
  469.      */
  470.     public function removeSubscription(Subscription $subscription): self
  471.     {
  472.         if ($this->subscriptions->contains($subscription)) {
  473.             $this->subscriptions->remove($subscription);
  474.             $subscription->setProduct(null);
  475.         }
  476.         return $this;
  477.     }
  478.     /**
  479.      * @return Space|null
  480.      */
  481.     public function getSpace(): ?Space
  482.     {
  483.         return $this->space;
  484.     }
  485.     /**
  486.      * @param Space|null $space
  487.      */
  488.     public function setSpace(?Space $space): void
  489.     {
  490.         $this->space $space;
  491.     }
  492.     /**
  493.      * @return Collection<int, ProductPrice>
  494.      */
  495.     public function getProductPrices(): Collection
  496.     {
  497.         return $this->productPrices;
  498.     }
  499.     /**
  500.      * @param ProductPrice $productPrice
  501.      * @return $this
  502.      */
  503.     public function addProductPrice(ProductPrice $productPrice): self
  504.     {
  505.         if (!$this->productPrices->contains($productPrice)) {
  506.             $this->productPrices[] = $productPrice;
  507.             $productPrice->setProduct($this);
  508.         }
  509.         return $this;
  510.     }
  511.     /**
  512.      * @param ProductPrice $productPrice
  513.      * @return $this
  514.      */
  515.     public function removeProductPrice(ProductPrice $productPrice): self
  516.     {
  517.         if ($this->productPrices->removeElement($productPrice)) {
  518.             // set the owning side to null (unless already changed)
  519.             if ($productPrice->getProduct() === $this) {
  520.                 $productPrice->setProduct(null);
  521.             }
  522.         }
  523.         return $this;
  524.     }
  525.     /**
  526.      * @return Collection<int, ProductPoint>
  527.      */
  528.     public function getProductPoints(): Collection
  529.     {
  530.         return $this->productPoints;
  531.     }
  532.     /**
  533.      * @param ProductPoint $productPoint
  534.      * @return $this
  535.      */
  536.     public function addProductPoint(ProductPoint $productPoint): self
  537.     {
  538.         if (!$this->productPoints->contains($productPoint)) {
  539.             $this->productPoints[] = $productPoint;
  540.             $productPoint->setProduct($this);
  541.         }
  542.         return $this;
  543.     }
  544.     /**
  545.      * @param ProductPoint $productPoint
  546.      * @return $this
  547.      */
  548.     public function removeProductPoint(ProductPoint $productPoint): self
  549.     {
  550.         // set the owning side to null (unless already changed)
  551.         if ($this->productPoints->removeElement($productPoint) && $productPoint->getProduct() === $this) {
  552.             $productPoint->setProduct(null);
  553.         }
  554.         return $this;
  555.     }
  556.     /**
  557.      * @return Collection<int, ProductPrediction>
  558.      */
  559.     public function getProductPredictions(): Collection
  560.     {
  561.         return $this->productPredictions;
  562.     }
  563.     /**
  564.      * @param ProductPrediction $productPrediction
  565.      * @return $this
  566.      */
  567.     public function addProductPrediction(ProductPrediction $productPrediction): self
  568.     {
  569.         if (!$this->productPredictions->contains($productPrediction)) {
  570.             $this->productPredictions[] = $productPrediction;
  571.             $productPrediction->setProduct($this);
  572.         }
  573.         return $this;
  574.     }
  575.     /**
  576.      * @param ProductPrediction $productPrediction
  577.      * @return $this
  578.      */
  579.     public function removeProductPrediction(ProductPrediction $productPrediction): self
  580.     {
  581.         if ($this->productPredictions->removeElement($productPrediction)) {
  582.             // set the owning side to null (unless already changed)
  583.             if ($productPrediction->getProduct() === $this) {
  584.                 $productPrediction->setProduct(null);
  585.             }
  586.         }
  587.         return $this;
  588.     }
  589.     /**
  590.      * @return bool
  591.      */
  592.     public function isPrediction(): bool
  593.     {
  594.         if (null === $this->sku) {
  595.             return false;
  596.         }
  597.         // On regarde si le SKU contient "prediction"
  598.         return === strpos($this->sku'prediction');
  599.     }
  600.     /**
  601.      * @return int
  602.      */
  603.     public function getProductQuantity(): int
  604.     {
  605.         if (null === $this->context || !isset($this->context['quantity'])) {
  606.             return 0;
  607.         }
  608.         return $this->context['quantity'];
  609.     }
  610.     /**
  611.      * @return Collection<int, TradeMarket>
  612.      */
  613.     public function getTradeMarkets(): Collection
  614.     {
  615.         return $this->tradeMarkets;
  616.     }
  617.     /**
  618.      * @param TradeMarket $tradeMarket
  619.      * @return $this
  620.      */
  621.     public function addTradeMarket(TradeMarket $tradeMarket): self
  622.     {
  623.         if (!$this->tradeMarkets->contains($tradeMarket)) {
  624.             $this->tradeMarkets[] = $tradeMarket;
  625.             $tradeMarket->addProduct($this);
  626.         }
  627.         return $this;
  628.     }
  629.     /**
  630.      * @param TradeMarket $tradeMarket
  631.      * @return $this
  632.      */
  633.     public function removeTradeMarket(TradeMarket $tradeMarket): self
  634.     {
  635.         if ($this->tradeMarkets->removeElement($tradeMarket)) {
  636.             $tradeMarket->removeProduct($this);
  637.         }
  638.         return $this;
  639.     }
  640.     public function getContext(): ?array
  641.     {
  642.         return $this->context;
  643.     }
  644.     public function setContext(?array $context): self
  645.     {
  646.         $this->context $context;
  647.         return $this;
  648.     }
  649. }