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.     public function __construct()
  163.     {
  164.         $this->propositionDetails = new ArrayCollection();
  165.         $this->orderDetails = new ArrayCollection();
  166.         $this->carts = new ArrayCollection();
  167.         $this->forecastDetails = new ArrayCollection();
  168.         $this->photos = new ArrayCollection();
  169.         $this->stockpharmacies = new ArrayCollection();
  170.         $this->createdAt = new \DateTime();
  171.         $this->searchHistories = new ArrayCollection();
  172.         $this->favorites = new ArrayCollection();
  173.     }
  174.     public function __toString()
  175.     {
  176.         return $this->getName();
  177.     }
  178.     public function getId(): ?int
  179.     {
  180.         return $this->id;
  181.     }
  182.     public function getName(): ?string
  183.     {
  184.         return $this->name;
  185.     }
  186.     public function setName(string $name): self
  187.     {
  188.         $this->name $name;
  189.         return $this;
  190.     }
  191.     public function getDescription(): ?string
  192.     {
  193.         return $this->description;
  194.     }
  195.     public function setDescription(?string $description): self
  196.     {
  197.         $this->description $description;
  198.         return $this;
  199.     }
  200.     public function getCip7(): ?string
  201.     {
  202.         return $this->cip7;
  203.     }
  204.     public function setCip7(?string $cip7): self
  205.     {
  206.         $this->cip7 $cip7;
  207.         return $this;
  208.     }
  209.     public function getCip13(): ?string
  210.     {
  211.         return $this->cip13;
  212.     }
  213.     public function setCip13(?string $cip13): self
  214.     {
  215.         $this->cip13 $cip13;
  216.         return $this;
  217.     }
  218.     public function getPricegrossiste(): ?float
  219.     {
  220.         return $this->pricegrossiste;
  221.     }
  222.     public function setPricegrossiste(?float $pricegrossiste): self
  223.     {
  224.         $this->pricegrossiste $pricegrossiste;
  225.         return $this;
  226.     }
  227.     public function getPricepharmacie(): ?float
  228.     {
  229.         return $this->pricepharmacie;
  230.     }
  231.     public function setPricepharmacie(?float $pricepharmacie): self
  232.     {
  233.         $this->pricepharmacie $pricepharmacie;
  234.         return $this;
  235.     }
  236.     public function getQuantity(): ?int
  237.     {
  238.         return $this->quantity;
  239.     }
  240.     public function setQuantity(?int $quantity): self
  241.     {
  242.         $this->quantity $quantity;
  243.         return $this;
  244.     }
  245.     public function getCollissage(): ?string
  246.     {
  247.         return $this->collissage;
  248.     }
  249.     public function setCollissage(?string $collissage): self
  250.     {
  251.         $this->collissage $collissage;
  252.         return $this;
  253.     }
  254.     public function getQuantitymin(): ?int
  255.     {
  256.         return $this->quantitymin;
  257.     }
  258.     public function setQuantitymin(?int $quantitymin): self
  259.     {
  260.         $this->quantitymin $quantitymin;
  261.         return $this;
  262.     }
  263.     public function getAmm(): ?string
  264.     {
  265.         return $this->amm;
  266.     }
  267.     public function setAmm(?string $amm): self
  268.     {
  269.         $this->amm $amm;
  270.         return $this;
  271.     }
  272.     public function getCg(): ?string
  273.     {
  274.         return $this->cg;
  275.     }
  276.     public function setCg(?string $cg): self
  277.     {
  278.         $this->cg $cg;
  279.         return $this;
  280.     }
  281.     public function getDisponibilite(): ?string
  282.     {
  283.         return $this->disponibilite;
  284.     }
  285.     public function setDisponibilite(?string $disponibilite): self
  286.     {
  287.         $this->disponibilite $disponibilite;
  288.         return $this;
  289.     }
  290.     public function getCategory(): ?Category
  291.     {
  292.         return $this->category;
  293.     }
  294.     public function setCategory(?Category $category): self
  295.     {
  296.         $this->category $category;
  297.         return $this;
  298.     }
  299.     public function getSpecialite(): ?Speciality
  300.     {
  301.         return $this->specialite;
  302.     }
  303.     public function setSpecialite(?Speciality $specialite): self
  304.     {
  305.         $this->specialite $specialite;
  306.         return $this;
  307.     }
  308.     /**
  309.      * @return Collection<int, PropositionDetails>
  310.      */
  311.     public function getPropositionDetails(): Collection
  312.     {
  313.         return $this->propositionDetails;
  314.     }
  315.     public function addPropositionDetail(PropositionDetails $propositionDetail): self
  316.     {
  317.         if (!$this->propositionDetails->contains($propositionDetail)) {
  318.             $this->propositionDetails[] = $propositionDetail;
  319.             $propositionDetail->setProduct($this);
  320.         }
  321.         return $this;
  322.     }
  323.     public function removePropositionDetail(PropositionDetails $propositionDetail): self
  324.     {
  325.         if ($this->propositionDetails->removeElement($propositionDetail)) {
  326.             // set the owning side to null (unless already changed)
  327.             if ($propositionDetail->getProduct() === $this) {
  328.                 $propositionDetail->setProduct(null);
  329.             }
  330.         }
  331.         return $this;
  332.     }
  333.     /**
  334.      * @return Collection<int, OrderDetails>
  335.      */
  336.     public function getOrderDetails(): Collection
  337.     {
  338.         return $this->orderDetails;
  339.     }
  340.     public function addOrderDetail(OrderDetails $orderDetail): self
  341.     {
  342.         if (!$this->orderDetails->contains($orderDetail)) {
  343.             $this->orderDetails[] = $orderDetail;
  344.             $orderDetail->setProductId($this);
  345.         }
  346.         return $this;
  347.     }
  348.     public function removeOrderDetail(OrderDetails $orderDetail): self
  349.     {
  350.         if ($this->orderDetails->removeElement($orderDetail)) {
  351.             // set the owning side to null (unless already changed)
  352.             if ($orderDetail->getProductId() === $this) {
  353.                 $orderDetail->setProductId(null);
  354.             }
  355.         }
  356.         return $this;
  357.     }
  358.     public function getColisageType(): ?ColisageType
  359.     {
  360.         return $this->colisageType;
  361.     }
  362.     public function setColisageType(?ColisageType $colisageType): self
  363.     {
  364.         $this->colisageType $colisageType;
  365.         return $this;
  366.     }
  367.     /**
  368.      * @return Collection<int, Cart>
  369.      */
  370.     public function getCarts(): Collection
  371.     {
  372.         return $this->carts;
  373.     }
  374.     public function addCart(Cart $cart): self
  375.     {
  376.         if (!$this->carts->contains($cart)) {
  377.             $this->carts[] = $cart;
  378.             $cart->setProduit($this);
  379.         }
  380.         return $this;
  381.     }
  382.     public function removeCart(Cart $cart): self
  383.     {
  384.         if ($this->carts->removeElement($cart)) {
  385.             // set the owning side to null (unless already changed)
  386.             if ($cart->getProduit() === $this) {
  387.                 $cart->setProduit(null);
  388.             }
  389.         }
  390.         return $this;
  391.     }
  392.     public function getPays(): ?string
  393.     {
  394.         return $this->pays;
  395.     }
  396.     public function setPays(?string $pays): self
  397.     {
  398.         $this->pays $pays;
  399.         return $this;
  400.     }
  401.     public function getDeclinaisonform(): ?DeclinaisonForm
  402.     {
  403.         return $this->declinaisonform;
  404.     }
  405.     public function setDeclinaisonform(?DeclinaisonForm $declinaisonform): self
  406.     {
  407.         $this->declinaisonform $declinaisonform;
  408.         return $this;
  409.     }
  410.     public function getPrevisionarrivage(): ?int
  411.     {
  412.         return $this->previsionarrivage;
  413.     }
  414.     public function setPrevisionarrivage(?int $previsionarrivage): self
  415.     {
  416.         $this->previsionarrivage $previsionarrivage;
  417.         return $this;
  418.     }
  419.     public function getPayslocalisation(): ?Pays
  420.     {
  421.         return $this->payslocalisation;
  422.     }
  423.     public function setPayslocalisation(?Pays $payslocalisation): self
  424.     {
  425.         $this->payslocalisation $payslocalisation;
  426.         return $this;
  427.     }
  428.     public function getLaboratoire(): ?Laboratoire
  429.     {
  430.         return $this->laboratoire;
  431.     }
  432.     public function setLaboratoire(?Laboratoire $laboratoire): self
  433.     {
  434.         $this->laboratoire $laboratoire;
  435.         return $this;
  436.     }
  437.     public function getIndication(): ?string
  438.     {
  439.         return $this->indication;
  440.     }
  441.     public function setIndication(?string $indication): self
  442.     {
  443.         $this->indication $indication;
  444.         return $this;
  445.     }
  446.     /**
  447.      * @return Collection<int, ForecastDetails>
  448.      */
  449.     public function getForecastDetails(): Collection
  450.     {
  451.         return $this->forecastDetails;
  452.     }
  453.     public function addForecastDetail(ForecastDetails $forecastDetail): self
  454.     {
  455.         if (!$this->forecastDetails->contains($forecastDetail)) {
  456.             $this->forecastDetails[] = $forecastDetail;
  457.             $forecastDetail->setProduitId($this);
  458.         }
  459.         return $this;
  460.     }
  461.     public function removeForecastDetail(ForecastDetails $forecastDetail): self
  462.     {
  463.         if ($this->forecastDetails->removeElement($forecastDetail)) {
  464.             // set the owning side to null (unless already changed)
  465.             if ($forecastDetail->getProduitId() === $this) {
  466.                 $forecastDetail->setProduitId(null);
  467.             }
  468.         }
  469.         return $this;
  470.     }
  471.     /**
  472.      * @return Collection<int, Photo>
  473.      */
  474.     public function getPhotos(): Collection
  475.     {
  476.         return $this->photos;
  477.     }
  478.     public function addPhoto(Photo $photo): self
  479.     {
  480.         if (!$this->photos->contains($photo)) {
  481.             $this->photos[] = $photo;
  482.             $photo->setProduit($this);
  483.         }
  484.         return $this;
  485.     }
  486.     public function removePhoto(Photo $photo): self
  487.     {
  488.         if ($this->photos->removeElement($photo)) {
  489.             // set the owning side to null (unless already changed)
  490.             if ($photo->getProduit() === $this) {
  491.                 $photo->setProduit(null);
  492.             }
  493.         }
  494.         return $this;
  495.     }
  496.     /**
  497.      * @return Collection<int, Stockpharmacie>
  498.      */
  499.     public function getStockpharmacies(): Collection
  500.     {
  501.         return $this->stockpharmacies;
  502.     }
  503.     public function addStockpharmacy(Stockpharmacie $stockpharmacy): self
  504.     {
  505.         if (!$this->stockpharmacies->contains($stockpharmacy)) {
  506.             $this->stockpharmacies[] = $stockpharmacy;
  507.             $stockpharmacy->setProduit($this);
  508.         }
  509.         return $this;
  510.     }
  511.     public function removeStockpharmacy(Stockpharmacie $stockpharmacy): self
  512.     {
  513.         if ($this->stockpharmacies->removeElement($stockpharmacy)) {
  514.             // set the owning side to null (unless already changed)
  515.             if ($stockpharmacy->getProduit() === $this) {
  516.                 $stockpharmacy->setProduit(null);
  517.             }
  518.         }
  519.         return $this;
  520.     }
  521.     public function getPosologie(): ?string
  522.     {
  523.         return $this->posologie;
  524.     }
  525.     public function setPosologie(?string $posologie): self
  526.     {
  527.         $this->posologie $posologie;
  528.         return $this;
  529.     }
  530.     public function getCreatedAt(): ?\DateTimeInterface
  531.     {
  532.         return $this->createdAt;
  533.     }
  534.     public function setCreatedAt(?\DateTimeInterface $createdAt): self
  535.     {
  536.         $this->createdAt $createdAt;
  537.         return $this;
  538.     }
  539.     public function isIsStockPharmacie(): ?bool
  540.     {
  541.         return $this->isStockPharmacie;
  542.     }
  543.     public function setIsStockPharmacie(?bool $isStockPharmacie): self
  544.     {
  545.         $this->isStockPharmacie $isStockPharmacie;
  546.         return $this;
  547.     }
  548.     public function isIsOrdonnance(): ?bool
  549.     {
  550.         return $this->isOrdonnance;
  551.     }
  552.     public function setIsOrdonnance(?bool $isOrdonnance): self
  553.     {
  554.         $this->isOrdonnance $isOrdonnance;
  555.         return $this;
  556.     }
  557.     public function isIsPhotoNotFound(): ?bool
  558.     {
  559.         return $this->isPhotoNotFound;
  560.     }
  561.     public function setIsPhotoNotFound(?bool $isPhotoNotFound): self
  562.     {
  563.         $this->isPhotoNotFound $isPhotoNotFound;
  564.         return $this;
  565.     }
  566.     public function isIsDoublon(): ?bool
  567.     {
  568.         return $this->isDoublon;
  569.     }
  570.     public function setIsDoublon(?bool $isDoublon): self
  571.     {
  572.         $this->isDoublon $isDoublon;
  573.         return $this;
  574.     }
  575.     /**
  576.      * @return Collection<int, SearchHistory>
  577.      */
  578.     public function getSearchHistories(): Collection
  579.     {
  580.         return $this->searchHistories;
  581.     }
  582.     public function addSearchHistory(SearchHistory $searchHistory): self
  583.     {
  584.         if (!$this->searchHistories->contains($searchHistory)) {
  585.             $this->searchHistories[] = $searchHistory;
  586.             $searchHistory->setClickAfter($this);
  587.         }
  588.         return $this;
  589.     }
  590.     public function removeSearchHistory(SearchHistory $searchHistory): self
  591.     {
  592.         if ($this->searchHistories->removeElement($searchHistory)) {
  593.             // set the owning side to null (unless already changed)
  594.             if ($searchHistory->getClickAfter() === $this) {
  595.                 $searchHistory->setClickAfter(null);
  596.             }
  597.         }
  598.         return $this;
  599.     }
  600.     public function getSouscategorie(): ?SousCategorie
  601.     {
  602.         return $this->souscategorie;
  603.     }
  604.     public function setSouscategorie(?SousCategorie $souscategorie): self
  605.     {
  606.         $this->souscategorie $souscategorie;
  607.         return $this;
  608.     }
  609.     /**
  610.      * @return Collection<int, Favorite>
  611.      */
  612.     public function getFavorites(): Collection
  613.     {
  614.         return $this->favorites;
  615.     }
  616.     public function addFavorite(Favorite $favorite): self
  617.     {
  618.         if (!$this->favorites->contains($favorite)) {
  619.             $this->favorites[] = $favorite;
  620.             $favorite->setProduct($this);
  621.         }
  622.         return $this;
  623.     }
  624.     public function removeFavorite(Favorite $favorite): self
  625.     {
  626.         if ($this->favorites->removeElement($favorite)) {
  627.             // set the owning side to null (unless already changed)
  628.             if ($favorite->getProduct() === $this) {
  629.                 $favorite->setProduct(null);
  630.             }
  631.         }
  632.         return $this;
  633.     }
  634.     public function isMyFavorite(User $user): bool
  635.     {
  636.         foreach ($this->getFavorites() as $favorite) {
  637.             if ($favorite->getUser() === $user) {
  638.                 return true;
  639.             }
  640.         }
  641.         return false;
  642.     }
  643.     public function getPhoto(): ?Photo
  644.     {
  645.         if ($this->getPhotos()->count() > 0) {
  646.             return $this->getPhotos()->first();
  647.         }
  648.         return null;
  649.     }
  650.     public function isStockDisponible()
  651.     {
  652.         $disponibilite null;
  653.         if ($this->getStockpharmacies()->count() > 0) {
  654.             $disponibilite false;
  655.             foreach ($this->getStockpharmacies() as $stock) {
  656.                 if ($stock->isIsDisponible()) {
  657.                     $disponibilite true;
  658.                     break;
  659.                 }
  660.             }
  661.         }
  662.         return $disponibilite;
  663.     }
  664. }