src/Entity/Produit.php line 31

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ProduitRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Symfony\Component\Serializer\Annotation\Groups;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. use ApiPlatform\Core\Annotation\ApiFilter;
  10. use ApiPlatform\Core\Annotation\ApiResource;
  11. use Doctrine\ORM\Mapping\OrderBy;
  12. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  13. use ApiPlatform\Core\Bridge\Elasticsearch\DataProvider\Filter\OrderFilter;
  14. use Symfony\Component\Serializer\Annotation\SerializedName;
  15. /**
  16.  * @ORM\Entity(repositoryClass=ProduitRepository::class)
  17.  *  * @ApiResource(
  18.  * normalizationContext={"groups"={"produit:read"}, "skip_null_values" = false},
  19.  *
  20.  * denormalizationContext={"groups"={"produit:write"}} ,
  21.  *     attributes= {"pagination_items_per_page" = 10},
  22.  *     order= {"id" = "DESC"},
  23.  *     )
  24.  * @ApiFilter(SearchFilter::class, properties={"nom" : "partial"})
  25.  * @ApiFilter(OrderFilter::class, properties={"id" : "DESC"})
  26.  */
  27. class Produit
  28. {
  29.     /**
  30.      * @ORM\Id
  31.      * @ORM\GeneratedValue
  32.      * @ORM\Column(type="integer")
  33.      *  @Groups({"produit:read","commandes:read","user:read","panier"})
  34.      */
  35.     private $id;
  36.     /**
  37.      * @SerializedName("libelle")
  38.      * @ORM\Column(type="string", length=255, nullable=true)
  39.      * @Groups({"produit:read","commandes:read","user:read","panier"})
  40.      */
  41.     private $nom;
  42.     /**
  43.      * @ORM\Column(type="text", nullable=true)
  44.      * @Groups({"produit:read","commandes:read","user:read","panier"})
  45.      */
  46.     private $description;
  47.     /**
  48.      * @ORM\Column(type="float", nullable=true)
  49.      * @Groups({"produit:read","commandes:read","user:read","panier"})
  50.      */
  51.     private $prix;
  52.     /** @Gedmo\Slug(fields={"nom"})
  53.      * @ORM\Column(type="string", length=255)
  54.      */
  55.     private $slug;
  56.     /**
  57.      * @ORM\Column(type="datetime", nullable=true)
  58.      * @Gedmo\Timestampable(on="create")
  59.      */
  60.     private $createdAt;
  61.     /**
  62.      * @ORM\Column(type="datetime", nullable=true)
  63.      * @Gedmo\Timestampable(on="update")
  64.      */
  65.     private $updateAt;
  66.    /**
  67.      * @ORM\ManyToOne(targetEntity=Categorie::class, inversedBy="produits")
  68.      * @Groups({"produit:read","commandes:read","produit:write"})
  69.      */
  70.     private $categorie;
  71.     /**
  72.      * @ORM\OneToMany(targetEntity=ImagesProduit::class, mappedBy="produit",cascade={"persist"})
  73.      * @Groups({"produit:read","commandes:read","user:read","panier"})
  74.      */
  75.     private $images;
  76.     /**
  77.      *  @ORM\Column(type="datetime", nullable=true)
  78.      * @Groups({"produit:read","commandes:read","user:read","panier"})
  79.      * @SerializedName("disponibilite")
  80.      */
  81.     private $Disponibilite;
  82.     /**
  83.      * @ORM\ManyToOne(targetEntity=Quartier::class, inversedBy="produit")
  84.      * @Groups({"produit:read","commandes:read","user:read","panier"})
  85.      */
  86.     private $localite;
  87.     /**
  88.      * @ORM\Column(type="string", length=255, nullable=true)
  89.      * @Groups({"produit:read","commandes:read","user:read","panier"})
  90.      */
  91.     private $acteur;
  92.      /**
  93.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="produits")
  94.      * @Groups({"produit:read","commandes:read","produit:write"})
  95.      */
  96.     private $utilisateur;
  97.     /**
  98.      * @ORM\Column(type="boolean", nullable=true)
  99.      * @Groups({"produit:read","commandes:read","user:read","panier"})
  100.      */
  101.     private $valide;
  102.     /**
  103.      * @ORM\Column(type="datetime", nullable=true)
  104.      */
  105.     private $dateDisponibilite;
  106.     /**
  107.      * @ORM\Column(type="integer", nullable=true)
  108.      */
  109.     private $quantite;
  110.     /**
  111.      * @ORM\ManyToOne(targetEntity=Cooperative::class, inversedBy="produits")
  112.      */
  113.     private $cooperative;
  114.     /**
  115.      * @ORM\OneToMany(targetEntity=LignesApprovisionnement::class, mappedBy="Produit")
  116.      *
  117.      */
  118.     private $lignesApprovisionnements;
  119.     /**
  120.      * @ORM\OneToOne(targetEntity=Stocks::class, mappedBy="produit", cascade={"persist", "remove"})
  121.      * @Groups({"produit:read","commandes:read","user:read","panier"})
  122.      */
  123.     private $stocks;
  124.     /**
  125.      * @ORM\ManyToOne(targetEntity=Items::class, inversedBy="produits")
  126.      * @Groups({"produit:read","commandes:read","produit:write"})
  127.      */
  128.     private $item;
  129.     
  130.     public function __construct()
  131.     {
  132.         $this->categories = new ArrayCollection();
  133.         $this->images = new ArrayCollection();
  134.         $this->valide true;
  135.         $this->lignesApprovisionnements = new ArrayCollection();
  136.     }
  137.     public function getId(): ?int
  138.     {
  139.         return $this->id;
  140.     }
  141.     public function getNom(): ?string
  142.     {
  143.         return $this->nom;
  144.     }
  145.     public function setNom(?string $nom): self
  146.     {
  147.         $this->nom $nom;
  148.         return $this;
  149.     }
  150.     public function getDescription(): ?string
  151.     {
  152.         return $this->description;
  153.     }
  154.     public function setDescription(?string $description): self
  155.     {
  156.         $this->description $description;
  157.         return $this;
  158.     }
  159.     public function getPrix(): ?float
  160.     {
  161.         return $this->prix;
  162.     }
  163.     public function setPrix(?float $prix): self
  164.     {
  165.         $this->prix $prix;
  166.         return $this;
  167.     }
  168.     public function getSlug(): ?string
  169.     {
  170.         return $this->slug;
  171.     }
  172.     public function setSlug(string $slug): self
  173.     {
  174.         $this->slug $slug;
  175.         return $this;
  176.     }
  177.     public function getCreatedAt(): ?\DateTimeInterface
  178.     {
  179.         return $this->createdAt;
  180.     }
  181.     public function setCreatedAt(?\DateTimeInterface $createdAt): self
  182.     {
  183.         $this->createdAt $createdAt;
  184.         return $this;
  185.     }
  186.     public function getUpdateAt(): ?\DateTimeInterface
  187.     {
  188.         return $this->updateAt;
  189.     }
  190.     public function setUpdateAt(?\DateTimeInterface $updateAt): self
  191.     {
  192.         $this->updateAt $updateAt;
  193.         return $this;
  194.     }
  195.     /**
  196.      * @return Collection<int, Categorie>
  197.      */
  198.     public function getCategories(): Collection
  199.     {
  200.         return $this->categories;
  201.     }
  202.     public function addCategory(Categorie $category): self
  203.     {
  204.         if (!$this->categories->contains($category)) {
  205.             $this->categories[] = $category;
  206.             $category->addProduit($this);
  207.         }
  208.         return $this;
  209.     }
  210.     public function removeCategory(Categorie $category): self
  211.     {
  212.         if ($this->categories->removeElement($category)) {
  213.             $category->removeProduit($this);
  214.         }
  215.         return $this;
  216.     }
  217.     /**
  218.      * @return Collection<int, ImagesProduit>
  219.      */
  220.     public function getImages(): Collection
  221.     {
  222.         return $this->images;
  223.     }
  224.     public function addImage(ImagesProduit $image): self
  225.     {
  226.         if (!$this->images->contains($image)) {
  227.             $this->images[] = $image;
  228.             $image->setProduit($this);
  229.         }
  230.         return $this;
  231.     }
  232.     public function removeImage(ImagesProduit $image): self
  233.     {
  234.         if ($this->images->removeElement($image)) {
  235.             // set the owning side to null (unless already changed)
  236.             if ($image->getProduit() === $this) {
  237.                 $image->setProduit(null);
  238.             }
  239.         }
  240.         return $this;
  241.     }
  242.     public function getQuantite(): ?int
  243.     {
  244.         return $this->quantite;
  245.     }
  246.     public function setQuantite(?int $quantite): self
  247.     {
  248.         $this->quantite $quantite;
  249.         return $this;
  250.     }
  251.     public function getDisponibilite(): ?\DateTime
  252.     {
  253.         return $this->Disponibilite;
  254.     }
  255.     public function setDisponibilite(?\DateTime $Disponibilite): self
  256.     {
  257.         $this->Disponibilite $Disponibilite;
  258.         return $this;
  259.     }
  260.     public function getLocalite(): ?Quartier
  261.     {
  262.         return $this->localite;
  263.     }
  264.     public function setLocalite(?Quartier $localite): self
  265.     {
  266.         $this->localite =$localite;
  267.         return $this;
  268.     }
  269.     public function getActeur(): ?string
  270.     {
  271.         return $this->acteur;
  272.     }
  273.     public function setActeur(?string $acteur): self
  274.     {
  275.         $this->acteur $acteur;
  276.         return $this;
  277.     }
  278.     public function getUtilisateur(): ?User
  279.     {
  280.         return $this->utilisateur;
  281.     }
  282.     public function setUtilisateur(?User $utilisateur): self
  283.     {
  284.         $this->utilisateur $utilisateur;
  285.         return $this;
  286.     }
  287.     public function getValide(): ?bool
  288.     {
  289.         return $this->valide;
  290.     }
  291.     public function setValide(?bool $valide): self
  292.     {
  293.         $this->valide $valide;
  294.         return $this;
  295.     }
  296.     public function getDateDisponibilite(): ?\DateTimeInterface
  297.     {
  298.         return $this->dateDisponibilite;
  299.     }
  300.     public function setDateDisponibilite(?\DateTimeInterface $dateDisponibilite): self
  301.     {
  302.         $this->dateDisponibilite $dateDisponibilite;
  303.         return $this;
  304.     }
  305.     public function getCooperative(): ?Cooperative
  306.     {
  307.         return $this->cooperative;
  308.     }
  309.     public function setCooperative(?Cooperative $cooperative): self
  310.     {
  311.         $this->cooperative $cooperative;
  312.         return $this;
  313.     }
  314.     /**
  315.      * @return Collection<int, LignesApprovisionnement>
  316.      */
  317.     public function getLignesApprovisionnements(): Collection
  318.     {
  319.         return $this->lignesApprovisionnements;
  320.     }
  321.     public function addLignesApprovisionnement(LignesApprovisionnement $lignesApprovisionnement): self
  322.     {
  323.         if (!$this->lignesApprovisionnements->contains($lignesApprovisionnement)) {
  324.             $this->lignesApprovisionnements[] = $lignesApprovisionnement;
  325.             $lignesApprovisionnement->setProduit($this);
  326.         }
  327.         return $this;
  328.     }
  329.     public function removeLignesApprovisionnement(LignesApprovisionnement $lignesApprovisionnement): self
  330.     {
  331.         if ($this->lignesApprovisionnements->removeElement($lignesApprovisionnement)) {
  332.             // set the owning side to null (unless already changed)
  333.             if ($lignesApprovisionnement->getProduit() === $this) {
  334.                 $lignesApprovisionnement->setProduit(null);
  335.             }
  336.         }
  337.         return $this;
  338.     }
  339.     public function getStocks(): ?Stocks
  340.     {
  341.         return $this->stocks;
  342.     }
  343.     public function setStocks(?Stocks $stocks): self
  344.     {
  345.         // unset the owning side of the relation if necessary
  346.         if ($stocks === null && $this->stocks !== null) {
  347.             $this->stocks->setProduit(null);
  348.         }
  349.         // set the owning side of the relation if necessary
  350.         if ($stocks !== null && $stocks->getProduit() !== $this) {
  351.             $stocks->setProduit($this);
  352.         }
  353.         $this->stocks $stocks;
  354.         return $this;
  355.     }
  356.     public function getCategorie(): ?Categorie
  357.     {
  358.         return $this->categorie;
  359.     }
  360.     public function setCategorie(?Categorie $categorie): self
  361.     {
  362.         $this->categorie $categorie;
  363.         return $this;
  364.     }
  365.     public function getItem(): ?items
  366.     {
  367.         return $this->item;
  368.     }
  369.     public function setItem(?items $item): self
  370.     {
  371.         $this->item $item;
  372.         return $this;
  373.     }
  374. }