src/Entity/Article.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ArticleRepository;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\HttpFoundation\File\File;
  8. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. #[ORM\Entity(repositoryClassArticleRepository::class)]
  11. #[Vich\Uploadable]
  12. class Article
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     private ?int $id null;
  18.     #[ORM\Column(length255)]
  19.     private ?string $titre null;
  20.     #[ORM\Column(length:11)]
  21.     private ?int $prix null;
  22.     #[ORM\Column(length:11)]
  23.     private ?int $quantite null;
  24.     #[ORM\Column(typeTypes::TEXT)]
  25.     private ?string $description null;
  26.     #[ORM\OneToMany(mappedBy'article'targetEntityCommandArticle::class, cascade: ['persist''remove'])]
  27.     private $commandes;
  28.     #[ORM\Column(type:'string'length:255)]
  29.     private $image;
  30.     #[Vich\UploadableField(mapping:'post_thumbnails'fileNameProperty:'image')]
  31.     private $imageFile;
  32.     #[ORM\Column(type:'string'length:255)]
  33.     private $extrait;
  34.     #[Vich\UploadableField(mapping:'post_thumbnails'fileNameProperty:'extrait')]
  35.     private $extraitFile;
  36.     public function __construct()
  37.     {
  38.         $this->commandes = new ArrayCollection();
  39.     }
  40.     public function getId(): ?int
  41.     {
  42.         return $this->id;
  43.     }
  44.     public function getTitre(): ?string
  45.     {
  46.         return $this->titre;
  47.     }
  48.     public function setTitre(string $titre): self
  49.     {
  50.         $this->titre $titre;
  51.         return $this;
  52.     }
  53.     public function getPrix(): ?int
  54.     {
  55.         return $this->prix;
  56.     }
  57.     
  58.     public function setPrix(int $prix): self
  59.     {
  60.         $this->prix $prix;
  61.         return $this;
  62.     }
  63.     public function setQuantite(int $quantite): self
  64.     {
  65.         $this->quantite $quantite;
  66.         return $this;
  67.     }
  68.     public function getQuantite(): ?int
  69.     {
  70.         return $this->quantite;
  71.     }
  72.     public function getDescription(): ?string
  73.     {
  74.         return $this->description;
  75.     }
  76.     public function setDescription(string $description): self
  77.     {
  78.         $this->description $description;
  79.         return $this;
  80.     }
  81.     public function setImageFile(File $image null)
  82.     {
  83.         $this->imageFile $image;
  84.         // VERY IMPORTANT:
  85.         // It is required that at least one field changes if you are using Doctrine,
  86.         // otherwise the event listeners won't be called and the file is lost
  87.         //  if ($image) {
  88.         // if 'updatedAt' is not defined in your entity, use another property
  89.         // $this->updatedAt = new \DateTime('now');
  90.         // }
  91.     }
  92.     public function getImageFile()
  93.     {
  94.         return $this->imageFile;
  95.     }
  96.     public function setImage($image)
  97.     {
  98.         $this->image $image;
  99.     }
  100.     public function getImage()
  101.     {
  102.         return $this->image;
  103.     }
  104.     public function setExtraitFile(File $extrait null)
  105.     {
  106.         $this->imageFile $extrait;
  107.         // VERY IMPORTANT:
  108.         // It is required that at least one field changes if you are using Doctrine,
  109.         // otherwise the event listeners won't be called and the file is lost
  110.         //  if ($image) {
  111.         // if 'updatedAt' is not defined in your entity, use another property
  112.         // $this->updatedAt = new \DateTime('now');
  113.         // }
  114.     }
  115.     public function getExtraitFile()
  116.     {
  117.         return $this->extraitFile;
  118.     }
  119.     public function setExtrait($extrait)
  120.     {
  121.         $this->extrait $extrait;
  122.     }
  123.     public function getExtrait()
  124.     {
  125.         return $this->extrait;
  126.     }
  127.     public function __toString()
  128.     {
  129.         return $this->titre;
  130.     }
  131.     /**
  132.      * @return Collection<int, CommandArticle>
  133.      */
  134.     public function getCommandes(): Collection
  135.     {
  136.         return $this->commandes;
  137.     }
  138.     public function addCommande(CommandArticle $commande): self
  139.     {
  140.         if (!$this->commandes->contains($commande)) {
  141.             $this->commandes->add($commande);
  142.             $commande->setArticle($this);
  143.         }
  144.         return $this;
  145.     }
  146.     public function removeCommande(CommandArticle $commande): self
  147.     {
  148.         if ($this->commandes->removeElement($commande)) {
  149.             // set the owning side to null (unless already changed)
  150.             if ($commande->getArticle() === $this) {
  151.                 $commande->setArticle(null);
  152.             }
  153.         }
  154.         return $this;
  155.     }
  156. }