<?php
namespace App\Entity;
use App\Entity\Futures\Feature;
use App\Entity\Futures\TradeMarket;
use App\Repository\ProductRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="app_product", uniqueConstraints={
* @ORM\UniqueConstraint(name="unique_product", columns={"type", "name"})
* })
* @ORM\Entity(repositoryClass=ProductRepository::class)
*/
class Product
{
// Produits Futures
public const SILVER_KEY = 'silver';
public const SILVER_MIRROR_KEY = 'silver_mirror';
public const SILVER_FULL_KEY = 'silver_full';
public const GOLD_KEY = 'gold';
public const GOLD_MIRROR_KEY = 'gold_mirror';
public const GOLD_PRO_KEY = 'gold_pro';
public const GOLD_FULL_KEY = 'gold_full';
public const PLATINIUM_KEY = 'platinium';
public const PREMIUM_KEY = 'premium';
public const NO_PACK = 'no_pack';
public const LINK_SUBSCRIPTION = "link_subscription";
// Le premium full permet de conditionner l'affichage des services mirrors
public const PREMIUM_FULL_KEY = 'premium_full';
public const AMBASSADOR_KEY = 'ambassador';
// Produits Luume
public const PRODUCT_CLEAAN_ELIXIR_KEY = "cleaan-elixir";
public const PRODUCT_PUURE_SHAPE_KEY = "puure-shape";
public const PRODUCT_DRAAIN_TEA_KEY = "draain-tea";
public const PRODUCT_MIND_FOCUUS_KEY = "mind-focuus";
public const PRODUCT_VITA_BOOST_KEY = "vita-boost";
public const PRODUCT_RELAAX_ME_KEY = "relaax-me";
public const PRODUCT_NEEO_SLIM_KEY = "neeo-slim";
public const PRODUCT_KONJAA_CONTROL_KEY = "konjaa-control";
public const PRODUCT_PUURE_BURN_KEY = "puure-burn";
public const PRODUCT_KERA_CAARE_KEY = "kera-caare";
public const PRODUCT_BIOTI_BOOST_KEY = "bioti-boost";
public const PRODUCT_COLLA_BLOOM_KEY = "colla-bloom";
public const PRODUCT_FLEXIA_KEY = "flexia";
public const PRODUCT_SILICIA_KEY = "silicia";
public const PRODUCT_PULSIA_KEY = "pulsia";
public const PRODUCT_DERMA_GLOW_KEY = "derma-glow";
public const PRODUCT_GLASS_GLOW_KEY = "glass-glow";
public const PRODUCT_VITALIUUM_KEY = "vitaliuum";
public const PACK_PERFORMANCE = "performance";
public const PACK_DETOX = "detox";
public const PACK_SLIMFIT = "slimfit";
public const PACK_HAIRFUSION = "hairfusion";
public const PACK_COLLAGENCARE = "collagencare";
public const PACK_COLLAGENBEAUTY = "collagenbeauty";
public const PROGRAM_DETOX = "detox-program";
public const PROGRAM_PERFORMANCE = "performance-program";
public const PROGRAM_SLIMFIT = "slimfit-program";
public const PROGRAM_HAIRFUSION = "hairfusion-program";
public const PROGRAM_SLIMGOLD = "slimgold-program";
public const PROGRAM_DECOUVERTE = "decouverte-program";
public const FORMATION_PACKAGE_DIGITAL_ECOM = "package-digital-ecom";
public const FORMATION_THEME_DIGITAL = "digital";
public const FORMATION_THEME_ECOM = "ecom";
public const FORMATION_THEME_FINANCE = "finance";
public const FORMATION_BOURSE = "bourse";
public const FORMATION_CRYPTO = "crypto";
public const FORMATION_TRADING = "trading";
public const NO_FORMATION = "no-formation";
public const FORMATION_TRACKING_COOKIE_NAME = "futures_learn_choice";
// On met une durée de formation à -1 pour représenter l'infini
public const FORMATION_DURATION = 1;
public const LUUME_PRODUCT_NAMES = [
self::PRODUCT_CLEAAN_ELIXIR_KEY,
self::PRODUCT_PUURE_SHAPE_KEY,
self::PRODUCT_DRAAIN_TEA_KEY,
self::PRODUCT_MIND_FOCUUS_KEY,
self::PRODUCT_VITA_BOOST_KEY,
self::PRODUCT_RELAAX_ME_KEY,
self::PRODUCT_NEEO_SLIM_KEY,
self::PRODUCT_KONJAA_CONTROL_KEY,
self::PRODUCT_PUURE_BURN_KEY,
self::PRODUCT_KERA_CAARE_KEY,
self::PRODUCT_BIOTI_BOOST_KEY,
self::PRODUCT_COLLA_BLOOM_KEY
];
public const LUUME_PACKS = [
self::PACK_PERFORMANCE,
self::PACK_DETOX,
self::PACK_SLIMFIT,
self::PACK_HAIRFUSION
];
public const LUUME_FORM_CHOICE_PACKS = [
self::PACK_PERFORMANCE => "Performance",
self::PACK_DETOX => "Detox",
self::PACK_SLIMFIT => "Slimfit",
self::PACK_HAIRFUSION => "Hairfusion"
];
public const FUTURES_PACK_IKIGAI_PLUS_CHOICE = [
self::PREMIUM_KEY => "Premium",
];
public const FUTURES_PACK_IKIGAI_CHOICE = [
self::GOLD_FULL_KEY => "Gold Full",
self::SILVER_FULL_KEY => "Silver Full",
];
// Produits Mybiz
public const IKIGAI_KEY = "ikigai";
public const IKIGAI_PLUS_KEY = "ikigai-plus";
public const PRODUCT_TYPE_LICENSE = "license";
public const PRODUCT_TYPE_PACK = "pack"; // Représente les produits de type pack (sous forme d'abonnement)
public const PRODUCT_TYPE_PROGRAM = "program"; // Représente (sur Luume) un ensemble de pack regroupé sous le même EAN
public const PRODUCT_TYPE_PRODUCT = "product"; // Représente les produits de type produit (sous forme de produit à l'unité)
public const PRODUCT_TYPE_PREDICTION = "prediction"; // Représente les produits de type prediction acheté indépendamment des souscriptions
public const PRODUCT_TYPE_FORMATION = "formation"; // Représente les académies de formation que l'on peut vendre (à commencer par digital et ecom)
public const PRODUCT_TYPE_LINK = "link"; // Représente la souscription Link c'est assez différent des autres cas
public const PRODUCT_PACK_STARTER = "starter";
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private ?int $id = null;
/**
* @ORM\Column(type="string", length=25)
*/
private ?string $type = null;
/**
* @ORM\Column(type="string", length=25)
*/
private ?string $name = null;
/**
* @ORM\Column(type="string", length=255, unique=true)
*/
private ?string $sku = null;
/**
* @ORM\Column(type="boolean")
*/
private bool $isEnabled = true;
/**
* @ORM\Column(type="boolean")
*/
private bool $isSubscibable = true;
/**
* @ORM\Column(type="boolean")
*/
private bool $isIkigaiPack = false;
/**
* Est-ce qu'on affiche ce produit à l'inscription sur Futures (prévu pour la transition des offres commerciales sur Futures)
* @ORM\Column(type="boolean")
*/
private bool $isPrintable = false;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Futures\Feature", inversedBy="products")
* @ORM\JoinTable(name="app_product_features")
*/
private ?Collection $features;
/**
* @ORM\OneToMany(targetEntity=Member::class, mappedBy="pack")
*/
private ?Collection $members;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $marketingName = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $imagePath = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $color = null;
/**
* @ORM\OneToMany(targetEntity=Subscription::class, mappedBy="product", orphanRemoval=true)
*/
private Collection $subscriptions;
/**
* @ORM\ManyToOne(targetEntity=Space::class, inversedBy="products")
* @ORM\JoinColumn(nullable=false)
*/
private ?Space $space = null;
/**
* @ORM\OneToMany(targetEntity=ProductPrice::class, mappedBy="product")
*/
private ?Collection $productPrices;
/**
* @ORM\OneToMany(targetEntity=ProductPoint::class, mappedBy="product")
*/
private ?Collection $productPoints;
/**
* @ORM\OneToMany(targetEntity=ProductPrediction::class, mappedBy="product")
*/
private ?Collection $productPredictions;
/**
* @ORM\ManyToMany(targetEntity=TradeMarket::class, mappedBy="products")
*/
private ?Collection $tradeMarkets;
/**
* @ORM\Column(type="json", nullable=true)
*/
private ?array $context = [];
public function __construct()
{
$this->features = new ArrayCollection();
$this->members = new ArrayCollection();
$this->subscriptions = new ArrayCollection();
$this->productPrices = new ArrayCollection();
$this->productPoints = new ArrayCollection();
$this->productPredictions = new ArrayCollection();
$this->tradeMarkets = new ArrayCollection();
}
/**
* @return int|null
*/
public function getId(): ?int
{
return $this->id;
}
/**
* @return string|null
*/
public function getType(): ?string
{
return $this->type;
}
/**
* @param string $type
* @return $this
*/
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
/**
* @return string|null
*/
public function getName(): ?string
{
return $this->name;
}
/**
* @param string $name
* @return $this
*/
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return string|null
*/
public function getSku(): ?string
{
return $this->sku;
}
/**
* @param string|null $sku
*/
public function setSku(?string $sku): void
{
$this->sku = $sku;
}
/**
* @return bool|null
*/
public function isEnabled(): ?bool
{
return $this->isEnabled;
}
/**
* @param bool $isEnabled
* @return $this
*/
public function setIsEnabled(bool $isEnabled): self
{
$this->isEnabled = $isEnabled;
return $this;
}
/**
* @return bool
*/
public function isSubscibable(): bool
{
return $this->isSubscibable;
}
/**
* @param bool $isSubscibable
*/
public function setIsSubscibable(bool $isSubscibable): void
{
$this->isSubscibable = $isSubscibable;
}
/**
* @return bool
*/
public function isIkigaiPack(): bool
{
return $this->isIkigaiPack;
}
/**
* @param bool $isIkigaiPack
*/
public function setIsIkigaiPack(bool $isIkigaiPack): void
{
$this->isIkigaiPack = $isIkigaiPack;
}
/**
* @return bool
*/
public function isPrintable(): bool
{
return $this->isPrintable;
}
/**
* @param bool $isPrintable
*/
public function setIsPrintable(bool $isPrintable): void
{
$this->isPrintable = $isPrintable;
}
/**
* @return Collection
*/
public function getFeatures(): Collection
{
return $this->features;
}
/**
* @param Feature $feature
* @return bool
*/
public function hasFeature(Feature $feature): bool
{
return $this->features->contains($feature);
}
/**
* @param Feature $feature
* @return $this
*/
public function addFeature(Feature $feature): self
{
if ($this->features->contains($feature)) {
return $this;
}
$this->features->add($feature);
return $this;
}
/**
* @param Feature $feature
* @return $this
*/
public function removeFeature(Feature $feature): self
{
if (!$this->features->contains($feature)) {
return $this;
}
$this->features->remove($feature);
return $this;
}
/**
* @return Collection|null
*/
public function getMembers(): ?Collection
{
return $this->members;
}
/**
* @param Member $member
* @return $this
*/
public function addMember(Member $member): self
{
if ($this->members->contains($member)) {
return $this;
}
$this->members->add($member);
return $this;
}
/**
* @param Member $member
* @return $this
*/
public function removeMember(Member $member): self
{
if (!$this->members->contains($member)) {
return $this;
}
$this->members->remove($member);
return $this;
}
/**
* @return string
*/
public function __toString(): string
{
return $this->getName();
}
/**
* @return string|null
*/
public function getMarketingName(): ?string
{
return $this->marketingName;
}
/**
* @param string|null $marketingName
* @return $this
*/
public function setMarketingName(?string $marketingName): self
{
$this->marketingName = $marketingName;
return $this;
}
/**
* @return string|null
*/
public function getImagePath(): ?string
{
return $this->imagePath;
}
/**
* @param string|null $imagePath
* @return $this
*/
public function setImagePath(?string $imagePath): self
{
$this->imagePath = $imagePath;
return $this;
}
/**
* @return string|null
*/
public function getColor(): ?string
{
return $this->color;
}
/**
* @param string|null $color
*/
public function setColor(?string $color): void
{
$this->color = $color;
}
/**
* @return Collection
*/
public function getSubscriptions(): Collection
{
return $this->subscriptions;
}
/**
* @param Subscription $subscription
* @return $this
*/
public function addSubscription(Subscription $subscription): self
{
if (!$this->subscriptions->contains($subscription)) {
$this->subscriptions->add($subscription);
$subscription->setProduct($this);
}
return $this;
}
/**
* @param Subscription $subscription
* @return $this
*/
public function removeSubscription(Subscription $subscription): self
{
if ($this->subscriptions->contains($subscription)) {
$this->subscriptions->remove($subscription);
$subscription->setProduct(null);
}
return $this;
}
/**
* @return Space|null
*/
public function getSpace(): ?Space
{
return $this->space;
}
/**
* @param Space|null $space
*/
public function setSpace(?Space $space): void
{
$this->space = $space;
}
/**
* @return Collection<int, ProductPrice>
*/
public function getProductPrices(): Collection
{
return $this->productPrices;
}
/**
* @param ProductPrice $productPrice
* @return $this
*/
public function addProductPrice(ProductPrice $productPrice): self
{
if (!$this->productPrices->contains($productPrice)) {
$this->productPrices[] = $productPrice;
$productPrice->setProduct($this);
}
return $this;
}
/**
* @param ProductPrice $productPrice
* @return $this
*/
public function removeProductPrice(ProductPrice $productPrice): self
{
if ($this->productPrices->removeElement($productPrice)) {
// set the owning side to null (unless already changed)
if ($productPrice->getProduct() === $this) {
$productPrice->setProduct(null);
}
}
return $this;
}
/**
* @return Collection<int, ProductPoint>
*/
public function getProductPoints(): Collection
{
return $this->productPoints;
}
/**
* @param ProductPoint $productPoint
* @return $this
*/
public function addProductPoint(ProductPoint $productPoint): self
{
if (!$this->productPoints->contains($productPoint)) {
$this->productPoints[] = $productPoint;
$productPoint->setProduct($this);
}
return $this;
}
/**
* @param ProductPoint $productPoint
* @return $this
*/
public function removeProductPoint(ProductPoint $productPoint): self
{
// set the owning side to null (unless already changed)
if ($this->productPoints->removeElement($productPoint) && $productPoint->getProduct() === $this) {
$productPoint->setProduct(null);
}
return $this;
}
/**
* @return Collection<int, ProductPrediction>
*/
public function getProductPredictions(): Collection
{
return $this->productPredictions;
}
/**
* @param ProductPrediction $productPrediction
* @return $this
*/
public function addProductPrediction(ProductPrediction $productPrediction): self
{
if (!$this->productPredictions->contains($productPrediction)) {
$this->productPredictions[] = $productPrediction;
$productPrediction->setProduct($this);
}
return $this;
}
/**
* @param ProductPrediction $productPrediction
* @return $this
*/
public function removeProductPrediction(ProductPrediction $productPrediction): self
{
if ($this->productPredictions->removeElement($productPrediction)) {
// set the owning side to null (unless already changed)
if ($productPrediction->getProduct() === $this) {
$productPrediction->setProduct(null);
}
}
return $this;
}
/**
* @return bool
*/
public function isPrediction(): bool
{
if (null === $this->sku) {
return false;
}
// On regarde si le SKU contient "prediction"
return 0 === strpos($this->sku, 'prediction');
}
/**
* @return int
*/
public function getProductQuantity(): int
{
if (null === $this->context || !isset($this->context['quantity'])) {
return 0;
}
return $this->context['quantity'];
}
/**
* @return Collection<int, TradeMarket>
*/
public function getTradeMarkets(): Collection
{
return $this->tradeMarkets;
}
/**
* @param TradeMarket $tradeMarket
* @return $this
*/
public function addTradeMarket(TradeMarket $tradeMarket): self
{
if (!$this->tradeMarkets->contains($tradeMarket)) {
$this->tradeMarkets[] = $tradeMarket;
$tradeMarket->addProduct($this);
}
return $this;
}
/**
* @param TradeMarket $tradeMarket
* @return $this
*/
public function removeTradeMarket(TradeMarket $tradeMarket): self
{
if ($this->tradeMarkets->removeElement($tradeMarket)) {
$tradeMarket->removeProduct($this);
}
return $this;
}
public function getContext(): ?array
{
return $this->context;
}
public function setContext(?array $context): self
{
$this->context = $context;
return $this;
}
}