src/Entity/Product.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ProductRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=ProductRepository::class)
  9.  */
  10. class Product
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=255)
  20.      */
  21.     private $name;
  22.     /**
  23.      * @ORM\Column(type="text", nullable=true)
  24.      */
  25.     private $description;
  26.     /**
  27.      * @ORM\Column(type="string", length=255, nullable=true)
  28.      */
  29.     private $cip7;
  30.     /**
  31.      * @ORM\Column(type="string", length=255, nullable=true)
  32.      */
  33.     private $cip13;
  34.     /**
  35.      * @ORM\Column(type="float", nullable=true)
  36.      */
  37.     private $pricegrossiste;
  38.     /**
  39.      * @ORM\Column(type="float", nullable=true)
  40.      */
  41.     private $pricepharmacie;
  42.     /**
  43.      * @ORM\Column(type="integer", nullable=true)
  44.      */
  45.     private $quantity;
  46.     /**
  47.      * @ORM\Column(type="string", length=255, nullable=true)
  48.      */
  49.     private $collissage;
  50.     /**
  51.      * @ORM\Column(type="integer", nullable=true)
  52.      */
  53.     private $quantitymin;
  54.     /**
  55.      * @ORM\Column(type="string", length=255, nullable=true)
  56.      */
  57.     private $amm;
  58.     /**
  59.      * @ORM\Column(type="string", length=255, nullable=true)
  60.      */
  61.     private $cg;
  62.     /**
  63.      * @ORM\Column(type="string", length=255, nullable=true)
  64.      */
  65.     private $disponibilite;
  66.     /**
  67.      * @ORM\ManyToOne(targetEntity=Category::class, inversedBy="products")
  68.      */
  69.     private $category;
  70.     /**
  71.      * @ORM\ManyToOne(targetEntity=Speciality::class, inversedBy="products")
  72.      */
  73.     private $specialite;
  74.     /**
  75.      * @ORM\OneToMany(targetEntity=PropositionDetails::class, mappedBy="product")
  76.      */
  77.     private $propositionDetails;
  78.     /**
  79.      * @ORM\OneToMany(targetEntity=OrderDetails::class, mappedBy="product_id")
  80.      */
  81.     private $orderDetails;
  82.     /**
  83.      * @ORM\ManyToOne(targetEntity=ColisageType::class, inversedBy="products")
  84.      */
  85.     private $colisageType;
  86.     /**
  87.      * @ORM\OneToMany(targetEntity=Cart::class, mappedBy="produit")
  88.      */
  89.     private $carts;
  90.     /**
  91.      * @ORM\Column(type="string", length=255, nullable=true)
  92.      */
  93.     private $pays;
  94.     /**
  95.      * @ORM\ManyToOne(targetEntity=DeclinaisonForm::class, inversedBy="products")
  96.      */
  97.     private $declinaisonform;
  98.     /**
  99.      * @ORM\Column(type="integer", nullable=true)
  100.      */
  101.     private $previsionarrivage;
  102.     /**
  103.      * @ORM\ManyToOne(targetEntity=Pays::class, inversedBy="products")
  104.      */
  105.     private $payslocalisation;
  106.     /**
  107.      * @ORM\ManyToOne(targetEntity=Laboratoire::class, inversedBy="products")
  108.      */
  109.     private $laboratoire;
  110.     /**
  111.      * @ORM\Column(type="text", nullable=true)
  112.      */
  113.     private $indication;
  114.     /**
  115.      * @ORM\OneToMany(targetEntity=ForecastDetails::class, mappedBy="produit_id")
  116.      */
  117.     private $forecastDetails;
  118.     /**
  119.      * @ORM\OneToMany(targetEntity=Photo::class, mappedBy="produit")
  120.      */
  121.     private $photos;
  122.     /**
  123.      * @ORM\OneToMany(targetEntity=Stockpharmacie::class, mappedBy="produit")
  124.      */
  125.     private $stockpharmacies;
  126.     /**
  127.      * @ORM\Column(type="text", nullable=true)
  128.      */
  129.     private $posologie;
  130.     /**
  131.      * @ORM\Column(type="datetime", nullable=true)
  132.      */
  133.     private $createdAt;
  134.     /**
  135.      * @ORM\Column(type="boolean", nullable=true)
  136.      */
  137.     private $isStockPharmacie;
  138.     /**
  139.      * @ORM\Column(type="boolean", nullable=true)
  140.      */
  141.     private $isOrdonnance;
  142.     /**
  143.      * @ORM\Column(type="boolean", nullable=true)
  144.      */
  145.     private $isPhotoNotFound;
  146.     /**
  147.      * @ORM\Column(type="boolean", nullable=true)
  148.      */
  149.     private $isDoublon;
  150.     /**
  151.      * @ORM\OneToMany(targetEntity=SearchHistory::class, mappedBy="clickAfter")
  152.      */
  153.     private $searchHistories;
  154.     /**
  155.      * @ORM\ManyToOne(targetEntity=SousCategorie::class, inversedBy="products")
  156.      */
  157.     private $souscategorie;
  158.     /**
  159.      * @ORM\OneToMany(targetEntity=Favorite::class, mappedBy="product")
  160.      */
  161.     private $favorites;
  162.     /**
  163.      * @ORM\ManyToOne(targetEntity=ProductClass::class, inversedBy="products")
  164.      */
  165.     private $productClass;
  166.     public function __construct()
  167.     {
  168.         $this->propositionDetails = new ArrayCollection();
  169.         $this->orderDetails = new ArrayCollection();
  170.         $this->carts = new ArrayCollection();
  171.         $this->forecastDetails = new ArrayCollection();
  172.         $this->photos = new ArrayCollection();
  173.         $this->stockpharmacies = new ArrayCollection();
  174.         $this->createdAt = new \DateTime();
  175.         $this->searchHistories = new ArrayCollection();
  176.         $this->favorites = new ArrayCollection();
  177.     }
  178.     public function __toString()
  179.     {
  180.         return $this->getName();
  181.     }
  182.     public function getId(): ?int
  183.     {
  184.         return $this->id;
  185.     }
  186.     public function getName(): ?string
  187.     {
  188.         return $this->name;
  189.     }
  190.     public function setName(string $name): self
  191.     {
  192.         $this->name $name;
  193.         return $this;
  194.     }
  195.     public function getDescription(): ?string
  196.     {
  197.         return $this->description;
  198.     }
  199.     public function setDescription(?string $description): self
  200.     {
  201.         $this->description $description;
  202.         return $this;
  203.     }
  204.     public function getCip7(): ?string
  205.     {
  206.         return $this->cip7;
  207.     }
  208.     public function setCip7(?string $cip7): self
  209.     {
  210.         $this->cip7 $cip7;
  211.         return $this;
  212.     }
  213.     public function getCip13(): ?string
  214.     {
  215.         return $this->cip13;
  216.     }
  217.     public function setCip13(?string $cip13): self
  218.     {
  219.         $this->cip13 $cip13;
  220.         return $this;
  221.     }
  222.     public function getPricegrossiste(): ?float
  223.     {
  224.         return $this->pricegrossiste;
  225.     }
  226.     public function setPricegrossiste(?float $pricegrossiste): self
  227.     {
  228.         $this->pricegrossiste $pricegrossiste;
  229.         return $this;
  230.     }
  231.     public function getPricepharmacie(): ?float
  232.     {
  233.         return $this->pricepharmacie;
  234.     }
  235.     public function setPricepharmacie(?float $pricepharmacie): self
  236.     {
  237.         $this->pricepharmacie $pricepharmacie;
  238.         return $this;
  239.     }
  240.     public function getQuantity(): ?int
  241.     {
  242.         return $this->quantity;
  243.     }
  244.     public function setQuantity(?int $quantity): self
  245.     {
  246.         $this->quantity $quantity;
  247.         return $this;
  248.     }
  249.     public function getCollissage(): ?string
  250.     {
  251.         return $this->collissage;
  252.     }
  253.     public function setCollissage(?string $collissage): self
  254.     {
  255.         $this->collissage $collissage;
  256.         return $this;
  257.     }
  258.     public function getQuantitymin(): ?int
  259.     {
  260.         return $this->quantitymin;
  261.     }
  262.     public function setQuantitymin(?int $quantitymin): self
  263.     {
  264.         $this->quantitymin $quantitymin;
  265.         return $this;
  266.     }
  267.     public function getAmm(): ?string
  268.     {
  269.         return $this->amm;
  270.     }
  271.     public function setAmm(?string $amm): self
  272.     {
  273.         $this->amm $amm;
  274.         return $this;
  275.     }
  276.     public function getCg(): ?string
  277.     {
  278.         return $this->cg;
  279.     }
  280.     public function setCg(?string $cg): self
  281.     {
  282.         $this->cg $cg;
  283.         return $this;
  284.     }
  285.     public function getDisponibilite(): ?string
  286.     {
  287.         return $this->disponibilite;
  288.     }
  289.     public function setDisponibilite(?string $disponibilite): self
  290.     {
  291.         $this->disponibilite $disponibilite;
  292.         return $this;
  293.     }
  294.     public function getCategory(): ?Category
  295.     {
  296.         return $this->category;
  297.     }
  298.     public function setCategory(?Category $category): self
  299.     {
  300.         $this->category $category;
  301.         return $this;
  302.     }
  303.     public function getSpecialite(): ?Speciality
  304.     {
  305.         return $this->specialite;
  306.     }
  307.     public function setSpecialite(?Speciality $specialite): self
  308.     {
  309.         $this->specialite $specialite;
  310.         return $this;
  311.     }
  312.     /**
  313.      * @return Collection<int, PropositionDetails>
  314.      */
  315.     public function getPropositionDetails(): Collection
  316.     {
  317.         return $this->propositionDetails;
  318.     }
  319.     public function addPropositionDetail(PropositionDetails $propositionDetail): self
  320.     {
  321.         if (!$this->propositionDetails->contains($propositionDetail)) {
  322.             $this->propositionDetails[] = $propositionDetail;
  323.             $propositionDetail->setProduct($this);
  324.         }
  325.         return $this;
  326.     }
  327.     public function removePropositionDetail(PropositionDetails $propositionDetail): self
  328.     {
  329.         if ($this->propositionDetails->removeElement($propositionDetail)) {
  330.             // set the owning side to null (unless already changed)
  331.             if ($propositionDetail->getProduct() === $this) {
  332.                 $propositionDetail->setProduct(null);
  333.             }
  334.         }
  335.         return $this;
  336.     }
  337.     /**
  338.      * @return Collection<int, OrderDetails>
  339.      */
  340.     public function getOrderDetails(): Collection
  341.     {
  342.         return $this->orderDetails;
  343.     }
  344.     public function addOrderDetail(OrderDetails $orderDetail): self
  345.     {
  346.         if (!$this->orderDetails->contains($orderDetail)) {
  347.             $this->orderDetails[] = $orderDetail;
  348.             $orderDetail->setProductId($this);
  349.         }
  350.         return $this;
  351.     }
  352.     public function removeOrderDetail(OrderDetails $orderDetail): self
  353.     {
  354.         if ($this->orderDetails->removeElement($orderDetail)) {
  355.             // set the owning side to null (unless already changed)
  356.             if ($orderDetail->getProductId() === $this) {
  357.                 $orderDetail->setProductId(null);
  358.             }
  359.         }
  360.         return $this;
  361.     }
  362.     public function getColisageType(): ?ColisageType
  363.     {
  364.         return $this->colisageType;
  365.     }
  366.     public function setColisageType(?ColisageType $colisageType): self
  367.     {
  368.         $this->colisageType $colisageType;
  369.         return $this;
  370.     }
  371.     /**
  372.      * @return Collection<int, Cart>
  373.      */
  374.     public function getCarts(): Collection
  375.     {
  376.         return $this->carts;
  377.     }
  378.     public function addCart(Cart $cart): self
  379.     {
  380.         if (!$this->carts->contains($cart)) {
  381.             $this->carts[] = $cart;
  382.             $cart->setProduit($this);
  383.         }
  384.         return $this;
  385.     }
  386.     public function removeCart(Cart $cart): self
  387.     {
  388.         if ($this->carts->removeElement($cart)) {
  389.             // set the owning side to null (unless already changed)
  390.             if ($cart->getProduit() === $this) {
  391.                 $cart->setProduit(null);
  392.             }
  393.         }
  394.         return $this;
  395.     }
  396.     public function getPays(): ?string
  397.     {
  398.         return $this->pays;
  399.     }
  400.     public function setPays(?string $pays): self
  401.     {
  402.         $this->pays $pays;
  403.         return $this;
  404.     }
  405.     public function getDeclinaisonform(): ?DeclinaisonForm
  406.     {
  407.         return $this->declinaisonform;
  408.     }
  409.     public function setDeclinaisonform(?DeclinaisonForm $declinaisonform): self
  410.     {
  411.         $this->declinaisonform $declinaisonform;
  412.         return $this;
  413.     }
  414.     public function getPrevisionarrivage(): ?int
  415.     {
  416.         return $this->previsionarrivage;
  417.     }
  418.     public function setPrevisionarrivage(?int $previsionarrivage): self
  419.     {
  420.         $this->previsionarrivage $previsionarrivage;
  421.         return $this;
  422.     }
  423.     public function getPayslocalisation(): ?Pays
  424.     {
  425.         return $this->payslocalisation;
  426.     }
  427.     public function setPayslocalisation(?Pays $payslocalisation): self
  428.     {
  429.         $this->payslocalisation $payslocalisation;
  430.         return $this;
  431.     }
  432.     public function getLaboratoire(): ?Laboratoire
  433.     {
  434.         return $this->laboratoire;
  435.     }
  436.     public function setLaboratoire(?Laboratoire $laboratoire): self
  437.     {
  438.         $this->laboratoire $laboratoire;
  439.         return $this;
  440.     }
  441.     public function getIndication(): ?string
  442.     {
  443.         return $this->indication;
  444.     }
  445.     public function setIndication(?string $indication): self
  446.     {
  447.         $this->indication $indication;
  448.         return $this;
  449.     }
  450.     /**
  451.      * @return Collection<int, ForecastDetails>
  452.      */
  453.     public function getForecastDetails(): Collection
  454.     {
  455.         return $this->forecastDetails;
  456.     }
  457.     public function addForecastDetail(ForecastDetails $forecastDetail): self
  458.     {
  459.         if (!$this->forecastDetails->contains($forecastDetail)) {
  460.             $this->forecastDetails[] = $forecastDetail;
  461.             $forecastDetail->setProduitId($this);
  462.         }
  463.         return $this;
  464.     }
  465.     public function removeForecastDetail(ForecastDetails $forecastDetail): self
  466.     {
  467.         if ($this->forecastDetails->removeElement($forecastDetail)) {
  468.             // set the owning side to null (unless already changed)
  469.             if ($forecastDetail->getProduitId() === $this) {
  470.                 $forecastDetail->setProduitId(null);
  471.             }
  472.         }
  473.         return $this;
  474.     }
  475.     /**
  476.      * @return Collection<int, Photo>
  477.      */
  478.     public function getPhotos(): Collection
  479.     {
  480.         return $this->photos;
  481.     }
  482.     public function addPhoto(Photo $photo): self
  483.     {
  484.         if (!$this->photos->contains($photo)) {
  485.             $this->photos[] = $photo;
  486.             $photo->setProduit($this);
  487.         }
  488.         return $this;
  489.     }
  490.     public function removePhoto(Photo $photo): self
  491.     {
  492.         if ($this->photos->removeElement($photo)) {
  493.             // set the owning side to null (unless already changed)
  494.             if ($photo->getProduit() === $this) {
  495.                 $photo->setProduit(null);
  496.             }
  497.         }
  498.         return $this;
  499.     }
  500.     /**
  501.      * @return Collection<int, Stockpharmacie>
  502.      */
  503.     public function getStockpharmacies(): Collection
  504.     {
  505.         return $this->stockpharmacies;
  506.     }
  507.     public function addStockpharmacy(Stockpharmacie $stockpharmacy): self
  508.     {
  509.         if (!$this->stockpharmacies->contains($stockpharmacy)) {
  510.             $this->stockpharmacies[] = $stockpharmacy;
  511.             $stockpharmacy->setProduit($this);
  512.         }
  513.         return $this;
  514.     }
  515.     public function removeStockpharmacy(Stockpharmacie $stockpharmacy): self
  516.     {
  517.         if ($this->stockpharmacies->removeElement($stockpharmacy)) {
  518.             // set the owning side to null (unless already changed)
  519.             if ($stockpharmacy->getProduit() === $this) {
  520.                 $stockpharmacy->setProduit(null);
  521.             }
  522.         }
  523.         return $this;
  524.     }
  525.     public function getPosologie(): ?string
  526.     {
  527.         return $this->posologie;
  528.     }
  529.     public function setPosologie(?string $posologie): self
  530.     {
  531.         $this->posologie $posologie;
  532.         return $this;
  533.     }
  534.     public function getCreatedAt(): ?\DateTimeInterface
  535.     {
  536.         return $this->createdAt;
  537.     }
  538.     public function setCreatedAt(?\DateTimeInterface $createdAt): self
  539.     {
  540.         $this->createdAt $createdAt;
  541.         return $this;
  542.     }
  543.     public function isIsStockPharmacie(): ?bool
  544.     {
  545.         return $this->isStockPharmacie;
  546.     }
  547.     public function setIsStockPharmacie(?bool $isStockPharmacie): self
  548.     {
  549.         $this->isStockPharmacie $isStockPharmacie;
  550.         return $this;
  551.     }
  552.     public function isIsOrdonnance(): ?bool
  553.     {
  554.         return $this->isOrdonnance;
  555.     }
  556.     public function setIsOrdonnance(?bool $isOrdonnance): self
  557.     {
  558.         $this->isOrdonnance $isOrdonnance;
  559.         return $this;
  560.     }
  561.     public function isIsPhotoNotFound(): ?bool
  562.     {
  563.         return $this->isPhotoNotFound;
  564.     }
  565.     public function setIsPhotoNotFound(?bool $isPhotoNotFound): self
  566.     {
  567.         $this->isPhotoNotFound $isPhotoNotFound;
  568.         return $this;
  569.     }
  570.     public function isIsDoublon(): ?bool
  571.     {
  572.         return $this->isDoublon;
  573.     }
  574.     public function setIsDoublon(?bool $isDoublon): self
  575.     {
  576.         $this->isDoublon $isDoublon;
  577.         return $this;
  578.     }
  579.     /**
  580.      * @return Collection<int, SearchHistory>
  581.      */
  582.     public function getSearchHistories(): Collection
  583.     {
  584.         return $this->searchHistories;
  585.     }
  586.     public function addSearchHistory(SearchHistory $searchHistory): self
  587.     {
  588.         if (!$this->searchHistories->contains($searchHistory)) {
  589.             $this->searchHistories[] = $searchHistory;
  590.             $searchHistory->setClickAfter($this);
  591.         }
  592.         return $this;
  593.     }
  594.     public function removeSearchHistory(SearchHistory $searchHistory): self
  595.     {
  596.         if ($this->searchHistories->removeElement($searchHistory)) {
  597.             // set the owning side to null (unless already changed)
  598.             if ($searchHistory->getClickAfter() === $this) {
  599.                 $searchHistory->setClickAfter(null);
  600.             }
  601.         }
  602.         return $this;
  603.     }
  604.     public function getSouscategorie(): ?SousCategorie
  605.     {
  606.         return $this->souscategorie;
  607.     }
  608.     public function setSouscategorie(?SousCategorie $souscategorie): self
  609.     {
  610.         $this->souscategorie $souscategorie;
  611.         return $this;
  612.     }
  613.     /**
  614.      * @return Collection<int, Favorite>
  615.      */
  616.     public function getFavorites(): Collection
  617.     {
  618.         return $this->favorites;
  619.     }
  620.     public function addFavorite(Favorite $favorite): self
  621.     {
  622.         if (!$this->favorites->contains($favorite)) {
  623.             $this->favorites[] = $favorite;
  624.             $favorite->setProduct($this);
  625.         }
  626.         return $this;
  627.     }
  628.     public function removeFavorite(Favorite $favorite): self
  629.     {
  630.         if ($this->favorites->removeElement($favorite)) {
  631.             // set the owning side to null (unless already changed)
  632.             if ($favorite->getProduct() === $this) {
  633.                 $favorite->setProduct(null);
  634.             }
  635.         }
  636.         return $this;
  637.     }
  638.     public function isMyFavorite(User $user): bool
  639.     {
  640.         foreach ($this->getFavorites() as $favorite) {
  641.             if ($favorite->getUser() === $user) {
  642.                 return true;
  643.             }
  644.         }
  645.         return false;
  646.     }
  647.     public function getPhoto(): ?Photo
  648.     {
  649.         if ($this->getPhotos()->count() > 0) {
  650.             return $this->getPhotos()->first();
  651.         }
  652.         return null;
  653.     }
  654.     public function isStockDisponible()
  655.     {
  656.         $disponibilite null;
  657.         if ($this->getStockpharmacies()->count() > 0) {
  658.             $disponibilite false;
  659.             foreach ($this->getStockpharmacies() as $stock) {
  660.                 if ($stock->isIsDisponible()) {
  661.                     $disponibilite true;
  662.                     break;
  663.                 }
  664.             }
  665.         }
  666.         return $disponibilite;
  667.     }
  668.     public function getProductClass(): ?ProductClass
  669.     {
  670.         return $this->productClass;
  671.     }
  672.     public function setProductClass(?ProductClass $productClass): self
  673.     {
  674.         $this->productClass $productClass;
  675.         return $this;
  676.     }
  677. }