src/Entity/Article.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\ArticleRepository;
  5. use DateTime;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use Symfony\Component\HttpFoundation\File\File;
  11. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  12. /**
  13.  * @ORM\Entity(repositoryClass=ArticleRepository::class)
  14.  * @Vich\Uploadable
  15.  * @ApiResource(
  16.  *     collectionOperations={"get","post"},
  17.  *     itemOperations={"get","put","patch","delete"},
  18.  *     normalizationContext={"groups"={"article"}},
  19.  *     denormalizationContext={"groups"={"article"}},
  20.  *     attributes={"pagination_enabled"=false}
  21.  * )
  22.  */
  23. class Article
  24. {
  25.     /**
  26.      * @ORM\Id
  27.      * @ORM\GeneratedValue
  28.      * @ORM\Column(type="integer")
  29.      * @Groups("article")
  30.      */
  31.     private $id;
  32.     /**
  33.      * @ORM\Column(type="string", length=255)
  34.      * @Groups("article")
  35.      */
  36.     private $nameFr;
  37.     /**
  38.      * @ORM\Column(type="string", length=255, nullable=true)
  39.      * @Groups("article")
  40.      */
  41.     private $nameEn;
  42.     /**
  43.      * @ORM\Column(type="string", length=255, nullable=true)
  44.      * @Groups("article")
  45.      */
  46.     private $nameDe;
  47.     /**
  48.      * @ORM\Column(type="string", length=255, nullable=true)
  49.      * @Groups("article")
  50.      */
  51.     private $nameNl;
  52.     /**
  53.      * @ORM\Column(type="float")
  54.      * @Groups("article")
  55.      */
  56.     private $price;
  57.     /**
  58.      * @ORM\Column(type="boolean")
  59.      * @Groups("article")
  60.      */
  61.     private $isHighlight;
  62.     /**
  63.      * @ORM\Column(type="boolean")
  64.      * @Groups("article")
  65.      */
  66.     private $isVaryingWeight;
  67.     /**
  68.      * @ORM\Column(type="boolean")
  69.      * @Groups("article")
  70.      */
  71.     private $isActive;
  72.     /**
  73.      * @ORM\Column(type="string", length=255, nullable = true)
  74.      * @Groups("article")
  75.      * @var string
  76.      */
  77.     private $image;
  78.     /**
  79.      * @Vich\UploadableField(mapping="article_images", fileNameProperty="image")
  80.      * @var File
  81.      */
  82.     private $imageFile;
  83.     /**
  84.      * @ORM\Column(type="datetime", nullable = true)
  85.      * @var DateTime
  86.      */
  87.     private $updatedAt;
  88.     /**
  89.      * @ORM\Column(type="text", nullable=true)
  90.      * @Groups("article")
  91.      */
  92.     private $descriptionFr;
  93.     /**
  94.      * @ORM\Column(type="text", nullable=true)
  95.      * @Groups("article")
  96.      */
  97.     private $descriptionEn;
  98.     /**
  99.      * @ORM\Column(type="text", nullable=true)
  100.      * @Groups("article")
  101.      */
  102.     private $descriptionDe;
  103.     /**
  104.      * @ORM\Column(type="text", nullable=true)
  105.      * @Groups("article")
  106.      */
  107.     private $descriptionNl;
  108.     /**
  109.      * @ORM\Column(type="text", nullable=true)
  110.      * @Groups("article")
  111.      */
  112.     private $nutritionalValueFr;
  113.     /**
  114.      * @ORM\Column(type="text", nullable=true)
  115.      * @Groups("article")
  116.      */
  117.     private $nutritionalValueEn;
  118.     /**
  119.      * @ORM\Column(type="text", nullable=true)
  120.      * @Groups("article")
  121.      */
  122.     private $nutritionalValueDe;
  123.     /**
  124.      * @ORM\Column(type="text", nullable=true)
  125.      * @Groups("article")
  126.      */
  127.     private $nutritionalValueNl;
  128.     /**
  129.      * @ORM\Column(type="text", nullable=true)
  130.      * @Groups("article")
  131.      */
  132.     private $ingredientFr;
  133.     /**
  134.      * @ORM\Column(type="text", nullable=true)
  135.      * @Groups("article")
  136.      */
  137.     private $ingredientEn;
  138.     /**
  139.      * @ORM\Column(type="text", nullable=true)
  140.      * @Groups("article")
  141.      */
  142.     private $ingredientDe;
  143.     /**
  144.      * @ORM\Column(type="text", nullable=true)
  145.      * @Groups("article")
  146.      */
  147.     private $ingredientNl;
  148.     /**
  149.      * @ORM\Column(type="text", nullable=true)
  150.      * @Groups("article")
  151.      */
  152.     private $allergenFr;
  153.     /**
  154.      * @ORM\Column(type="text", nullable=true)
  155.      * @Groups("article")
  156.      */
  157.     private $allergenEn;
  158.     /**
  159.      * @ORM\Column(type="text", nullable=true)
  160.      * @Groups("article")
  161.      */
  162.     private $allergenDe;
  163.     /**
  164.      * @ORM\Column(type="text", nullable=true)
  165.      * @Groups("article")
  166.      */
  167.     private $allergenNl;
  168.     /**
  169.      * @ORM\Column(type="array", nullable=true)
  170.      * @Groups("article")
  171.      */
  172.     private $arrayPrice = [];
  173.     /**
  174.      * @ORM\ManyToOne(targetEntity=Family::class, inversedBy="articles")
  175.      * @Groups("article")
  176.      */
  177.     private $family;
  178.     /**
  179.      * @ORM\ManyToOne(targetEntity=Category::class, inversedBy="articles")
  180.      * @ORM\JoinColumn(name="category_id", referencedColumnName="id", onDelete="SET NULL")
  181.      * @Groups("article")
  182.      */
  183.     private $category;
  184.     /**
  185.      * @ORM\OneToMany(targetEntity=Promotion::class, mappedBy="article", orphanRemoval=true)
  186.      */
  187.     private $promotions;
  188.     /**
  189.      * @ORM\Column(type="integer", nullable = true))
  190.      * @Groups("article")
  191.      */
  192.     private $maxQty;
  193.     /**
  194.      * @ORM\Column(type="string", length=255, nullable=true)
  195.      * @Groups("article")
  196.      */
  197.     private $articleNumber;
  198.     /**
  199.      * @ORM\Column(type="integer", nullable=true)
  200.      * @Groups("article")
  201.      */
  202.     private $deliveryMin;
  203.     /**
  204.      * @ORM\Column(type="float", nullable=true)
  205.      * @Groups("article")
  206.      */
  207.     private $weightAverage;
  208.     /**
  209.      * @ORM\Column(type="string", length=255, nullable=true)
  210.      * @Groups("article")
  211.      */
  212.     private $packaging;
  213.     /**
  214.      * @ORM\Column(type="boolean")
  215.      * @Groups("article")
  216.      */
  217.     private $availability;
  218.     /**
  219.      * @ORM\Column(type="boolean")
  220.      * @Groups("article")
  221.      */
  222.     private $isIGP;
  223.     /**
  224.      * @ORM\OneToMany(targetEntity=Catalog::class, mappedBy="article", orphanRemoval=true)
  225.      */
  226.     private $catalogs;
  227.     /**
  228.      * @ORM\Column(type="text", nullable=true)
  229.      * @Groups("article")
  230.      */
  231.     private $technicalData;
  232.     /**
  233.      * @ORM\Column(type="boolean")
  234.      * @Groups("article")
  235.      */
  236.     private $isBulk;
  237.     public function __construct()
  238.     {
  239.         $this->promotions = new ArrayCollection();
  240.         $this->catalogs = new ArrayCollection();
  241.     }
  242.     public function convertArticleToArray(): array
  243.     {
  244.         $articleArray = [];
  245.         $articleArray["id"] = $this->getId();
  246.         $articleArray["nameFr"] = $this->getNameFr();
  247.         $articleArray["nameEn"] = $this->getNameEn();
  248.         $articleArray["nameDe"] = $this->getNameDe();
  249.         $articleArray["nameNl"] = $this->getNameNl();
  250.         $articleArray["descriptionFr"] = $this->getDescriptionFr();
  251.         $articleArray["descriptionEn"] = $this->getDescriptionEn();
  252.         $articleArray["descriptionDe"] = $this->getDescriptionNl();
  253.         $articleArray["descriptionNl"] = $this->getDescriptionDe();
  254.         $articleArray["price"] = $this->getPrice();
  255.         $articleArray["arrayPrice"] = $this->getArrayPrice();
  256.         $articleArray["isHighlight"] = $this->getIsHighlight();
  257.         $articleArray["isVaryingWeight"] = $this->getIsVaryingWeight();
  258.         $articleArray["nutritionalValueFr"] = $this->getNutritionalValueFr();
  259.         $articleArray["nutritionalValueEn"] = $this->getNutritionalValueEn();
  260.         $articleArray["nutritionalValueDe"] = $this->getNutritionalValueDe();
  261.         $articleArray["nutritionalValueNl"] = $this->getNutritionalValueNl();
  262.         $articleArray["ingredientFr"] = $this->getIngredientFr();
  263.         $articleArray["ingredientEn"] = $this->getIngredientEn();
  264.         $articleArray["ingredientDe"] = $this->getIngredientDe();
  265.         $articleArray["ingredientNl"] = $this->getIngredientNl();
  266.         $articleArray["allergenFr"] = $this->getAllergenFr();
  267.         $articleArray["allergenEn"] = $this->getAllergenEn();
  268.         $articleArray["allergenDe"] = $this->getAllergenDe();
  269.         $articleArray["allergenNl"] = $this->getAllergenNl();
  270.         $articleArray["isActive"] = $this->getIsActive();
  271.         $articleArray["maxQty"] = $this->getMaxQty();
  272.         $articleArray["isBulk"] = $this->getIsBulk();
  273.         if ($this->getImage()) {
  274.             $articleArray['image'] = true;
  275.         } else {
  276.             $articleArray['image'] = false;
  277.         }
  278.         return $articleArray;
  279.     }
  280.     public function getId(): ?int
  281.     {
  282.         return $this->id;
  283.     }
  284.     public function getPrice(): ?float
  285.     {
  286.         return $this->price;
  287.     }
  288.     public function setPrice(float $price): self
  289.     {
  290.         $this->price $price;
  291.         return $this;
  292.     }
  293.     public function getIsHighlight(): ?bool
  294.     {
  295.         return $this->isHighlight;
  296.     }
  297.     public function setIsHighlight(bool $isHighlight): self
  298.     {
  299.         $this->isHighlight $isHighlight;
  300.         return $this;
  301.     }
  302.     public function getIsVaryingWeight(): ?bool
  303.     {
  304.         return $this->isVaryingWeight;
  305.     }
  306.     public function setIsVaryingWeight(bool $isVaryingWeight): self
  307.     {
  308.         $this->isVaryingWeight $isVaryingWeight;
  309.         return $this;
  310.     }
  311.     public function getIsActive(): ?bool
  312.     {
  313.         return $this->isActive;
  314.     }
  315.     public function setIsActive(bool $isActive): self
  316.     {
  317.         $this->isActive $isActive;
  318.         return $this;
  319.     }
  320.     public function setImageFile(File $image null)
  321.     {
  322.         $this->imageFile $image;
  323.         // VERY IMPORTANT:
  324.         // It is required that at least one field changes if you are using Doctrine,
  325.         // otherwise the event listeners won't be called and the file is lost
  326.         if ($image) {
  327.             // if 'updatedAt' is not defined in your entity, use another property
  328.             $this->updatedAt = new \DateTime('now');
  329.         }
  330.     }
  331.     public function getUpdateAt()
  332.     {
  333.         return $this->updatedAt;
  334.     }
  335.     public function setUpdateAt(DateTime $dateTime)
  336.     {
  337.         $this->updatedAt $dateTime;
  338.     }
  339.     public function getImageFile()
  340.     {
  341.         return $this->imageFile;
  342.     }
  343.     public function setImage($image)
  344.     {
  345.         $this->image $image;
  346.     }
  347.     public function getImage()
  348.     {
  349.         return $this->image;
  350.     }
  351.     public function getNutritionalValueFr(): ?string
  352.     {
  353.         return $this->nutritionalValueFr;
  354.     }
  355.     public function setNutritionalValueFr(?string $nutritionalValueFr): self
  356.     {
  357.         $this->nutritionalValueFr $nutritionalValueFr;
  358.         return $this;
  359.     }
  360.     public function getNutritionalValueEn(): ?string
  361.     {
  362.         return $this->nutritionalValueEn;
  363.     }
  364.     public function setNutritionalValueEn(?string $nutritionalValueEn): self
  365.     {
  366.         $this->nutritionalValueEn $nutritionalValueEn;
  367.         return $this;
  368.     }
  369.     public function getNutritionalValueDe(): ?string
  370.     {
  371.         return $this->nutritionalValueDe;
  372.     }
  373.     public function setNutritionalValueDe(?string $nutritionalValueDe): self
  374.     {
  375.         $this->nutritionalValueDe $nutritionalValueDe;
  376.         return $this;
  377.     }
  378.     public function getNutritionalValueNl(): ?string
  379.     {
  380.         return $this->nutritionalValueNl;
  381.     }
  382.     public function setNutritionalValueNl(?string $nutritionalValueNl): self
  383.     {
  384.         $this->nutritionalValueNl $nutritionalValueNl;
  385.         return $this;
  386.     }
  387.     public function getIngredientFr(): ?string
  388.     {
  389.         return $this->ingredientFr;
  390.     }
  391.     public function setIngredientFr(?string $ingredientFr): self
  392.     {
  393.         $this->ingredientFr $ingredientFr;
  394.         return $this;
  395.     }
  396.     public function getIngredientEn(): ?string
  397.     {
  398.         return $this->ingredientEn;
  399.     }
  400.     public function setIngredientEn(?string $ingredientEn): self
  401.     {
  402.         $this->ingredientEn $ingredientEn;
  403.         return $this;
  404.     }
  405.     public function getIngredientDe(): ?string
  406.     {
  407.         return $this->ingredientDe;
  408.     }
  409.     public function setIngredientDe(?string $ingredientDe): self
  410.     {
  411.         $this->ingredientDe $ingredientDe;
  412.         return $this;
  413.     }
  414.     public function getIngredientNl(): ?string
  415.     {
  416.         return $this->ingredientNl;
  417.     }
  418.     public function setIngredientNl(?string $ingredientNl): self
  419.     {
  420.         $this->ingredientNl $ingredientNl;
  421.         return $this;
  422.     }
  423.     public function getAllergenFr(): ?string
  424.     {
  425.         return $this->allergenFr;
  426.     }
  427.     public function setAllergenFr(?string $allergenFr): self
  428.     {
  429.         $this->allergenFr $allergenFr;
  430.         return $this;
  431.     }
  432.     public function getAllergenEn(): ?string
  433.     {
  434.         return $this->allergenEn;
  435.     }
  436.     public function setAllergenEn(?string $allergenEn): self
  437.     {
  438.         $this->allergenEn $allergenEn;
  439.         return $this;
  440.     }
  441.     public function getAllergenDe(): ?string
  442.     {
  443.         return $this->allergenDe;
  444.     }
  445.     public function setAllergenDe(?string $allergenDe): self
  446.     {
  447.         $this->allergenDe $allergenDe;
  448.         return $this;
  449.     }
  450.     public function getAllergenNl(): ?string
  451.     {
  452.         return $this->allergenNl;
  453.     }
  454.     public function setAllergenNl(?string $allergenNl): self
  455.     {
  456.         $this->allergenNl $allergenNl;
  457.         return $this;
  458.     }
  459.     public function getDescriptionFr(): ?string
  460.     {
  461.         return $this->descriptionFr;
  462.     }
  463.     public function setDescriptionFr(?string $descriptionFr): self
  464.     {
  465.         $this->descriptionFr $descriptionFr;
  466.         return $this;
  467.     }
  468.     public function getDescriptionEn(): ?string
  469.     {
  470.         return $this->descriptionEn;
  471.     }
  472.     public function setDescriptionEn(?string $descriptionEn): self
  473.     {
  474.         $this->descriptionEn $descriptionEn;
  475.         return $this;
  476.     }
  477.     public function getDescriptionDe(): ?string
  478.     {
  479.         return $this->descriptionDe;
  480.     }
  481.     public function setDescriptionDe(?string $descriptionDe): self
  482.     {
  483.         $this->descriptionDe $descriptionDe;
  484.         return $this;
  485.     }
  486.     public function getDescriptionNl(): ?string
  487.     {
  488.         return $this->descriptionNl;
  489.     }
  490.     public function setDescriptionNl(?string $descriptionNl): self
  491.     {
  492.         $this->descriptionNl $descriptionNl;
  493.         return $this;
  494.     }
  495.     public function getNameFr(): ?string
  496.     {
  497.         return $this->nameFr;
  498.     }
  499.     public function setNameFr(string $nameFr): self
  500.     {
  501.         $this->nameFr $nameFr;
  502.         return $this;
  503.     }
  504.     public function getNameEn(): ?string
  505.     {
  506.         return $this->nameEn;
  507.     }
  508.     public function setNameEn(string $nameEn): self
  509.     {
  510.         $this->nameEn $nameEn;
  511.         return $this;
  512.     }
  513.     public function getNameDe(): ?string
  514.     {
  515.         return $this->nameDe;
  516.     }
  517.     public function setNameDe(string $nameDe): self
  518.     {
  519.         $this->nameDe $nameDe;
  520.         return $this;
  521.     }
  522.     public function getNameNl(): ?string
  523.     {
  524.         return $this->nameNl;
  525.     }
  526.     public function setNameNl(string $nameNl): self
  527.     {
  528.         $this->nameNl $nameNl;
  529.         return $this;
  530.     }
  531.     public function getArrayPrice(): ?array
  532.     {
  533.         return $this->arrayPrice;
  534.     }
  535.     public function setArrayPrice(?array $arrayPrice): self
  536.     {
  537.         $this->arrayPrice $arrayPrice;
  538.         return $this;
  539.     }
  540.     public function getFamily(): ?Family
  541.     {
  542.         return $this->family;
  543.     }
  544.     public function setFamily(?Family $family): self
  545.     {
  546.         $this->family $family;
  547.         return $this;
  548.     }
  549.     public function getCategory(): ?Category
  550.     {
  551.         return $this->category;
  552.     }
  553.     public function setCategory(?Category $category): self
  554.     {
  555.         $this->category $category;
  556.         return $this;
  557.     }
  558.     /**
  559.      * @return Collection|Promotion[]
  560.      */
  561.     public function getPromotions(): Collection
  562.     {
  563.         return $this->promotions;
  564.     }
  565.     public function addPromotion(Promotion $promotion): self
  566.     {
  567.         if (!$this->promotions->contains($promotion)) {
  568.             $this->promotions[] = $promotion;
  569.             $promotion->setArticle($this);
  570.         }
  571.         return $this;
  572.     }
  573.     public function removePromotion(Promotion $promotion): self
  574.     {
  575.         if ($this->promotions->removeElement($promotion)) {
  576.             // set the owning side to null (unless already changed)
  577.             if ($promotion->getArticle() === $this) {
  578.                 $promotion->setArticle(null);
  579.             }
  580.         }
  581.         return $this;
  582.     }
  583.     public function getMaxQty(): ?int
  584.     {
  585.         return $this->maxQty;
  586.     }
  587.     public function setMaxQty(?int $maxQty): self
  588.     {
  589.         $this->maxQty $maxQty;
  590.         return $this;
  591.     }
  592.     public function getArticleNumber(): ?string
  593.     {
  594.         return $this->articleNumber;
  595.     }
  596.     public function setArticleNumber(?string $articleNumber): self
  597.     {
  598.         $this->articleNumber $articleNumber;
  599.         return $this;
  600.     }
  601.     public function getDeliveryMin(): ?int
  602.     {
  603.         return $this->deliveryMin;
  604.     }
  605.     public function setDeliveryMin(?int $deliveryMin): self
  606.     {
  607.         $this->deliveryMin $deliveryMin;
  608.         return $this;
  609.     }
  610.     public function getWeightAverage(): ?float
  611.     {
  612.         return $this->weightAverage;
  613.     }
  614.     public function setWeightAverage(?float $weightAverage): self
  615.     {
  616.         $this->weightAverage $weightAverage;
  617.         return $this;
  618.     }
  619.     public function getPackaging(): ?string
  620.     {
  621.         return $this->packaging;
  622.     }
  623.     public function setPackaging(?string $packaging): self
  624.     {
  625.         $this->packaging $packaging;
  626.         return $this;
  627.     }
  628.     public function getIsIGP(): ?bool
  629.     {
  630.         return $this->isIGP;
  631.     }
  632.     public function setIsIGP(bool $isIGP): self
  633.     {
  634.         $this->isIGP $isIGP;
  635.         return $this;
  636.     }
  637.     public function getAvailability(): ?bool
  638.     {
  639.         return $this->availability;
  640.     }
  641.     public function setAvailability(bool $availability): self
  642.     {
  643.         $this->availability $availability;
  644.         return $this;
  645.     }
  646.     /**
  647.      * @return Collection|Catalog[]
  648.      */
  649.     public function getCatalogs(): Collection
  650.     {
  651.         return $this->catalogs;
  652.     }
  653.     public function addCatalog(Catalog $catalog): self
  654.     {
  655.         if (!$this->catalogs->contains($catalog)) {
  656.             $this->catalogs[] = $catalog;
  657.             $catalog->setArticle($this);
  658.         }
  659.         return $this;
  660.     }
  661.     public function removeCatalog(Catalog $catalog): self
  662.     {
  663.         if ($this->catalogs->removeElement($catalog)) {
  664.             // set the owning side to null (unless already changed)
  665.             if ($catalog->getArticle() === $this) {
  666.                 $catalog->setArticle(null);
  667.             }
  668.         }
  669.         return $this;
  670.     }
  671.     public function getTechnicalData(): ?string
  672.     {
  673.         return $this->technicalData;
  674.     }
  675.     public function setTechnicalData(?string $technicalData): self
  676.     {
  677.         $this->technicalData $technicalData;
  678.         return $this;
  679.     }
  680.     public function getIsBulk(): ?bool
  681.     {
  682.         return $this->isBulk;
  683.     }
  684.     public function setIsBulk(bool $isBulk): self
  685.     {
  686.         $this->isBulk $isBulk;
  687.         return $this;
  688.     }
  689. }