src/Entity/Product.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ProductRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\HttpFoundation\File\File;
  7. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. #[ORM\Entity(repositoryClassProductRepository::class)]
  10. #[Vich\Uploadable]
  11. class Product
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column(length255)]
  18.     private ?string $name null;
  19.     #[ORM\Column(length255)]
  20.     private ?string $sku null;
  21.     #[ORM\Column(typeTypes::TEXT)]
  22.     private ?string $description null;
  23.     #[ORM\Column(length255)]
  24.     private ?string $shortDescription null;
  25.     #[ORM\Column(length255)]
  26.     private ?string $metaTitle null;
  27.     #[ORM\Column(length255)]
  28.     private ?string $metaDescription null;
  29.     #[ORM\Column]
  30.     private ?int $category null;
  31.     // NOTE: This is not a mapped field of entity metadata, just a simple property.
  32.     #[Vich\UploadableField(mapping'product_image'fileNameProperty'image',originalName:'nomInitial')]
  33.     #[Assert\File(
  34.         maxSize'10M',
  35.         mimeTypes: ['image/jpeg'],
  36.         mimeTypesMessage'Veuillez télécharger une image valide en format JPG (10 Mo maximum)'
  37.     )]
  38.     private ?File $imageFile null;
  39.     #[ORM\Column(length255)]
  40.     private ?string $image null;
  41.     #[ORM\Column(length255,nullabletrue)]
  42.     private ?string $nomInitial null;
  43.     #[ORM\Column(length255)]
  44.     private ?string $tva null;
  45.     #[ORM\Column(length255)]
  46.     private ?string $url null;
  47.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  48.     private ?string $notes null;
  49.     public function getId(): ?int
  50.     {
  51.         return $this->id;
  52.     }
  53.     public function setId(): ?string
  54.     {
  55.         return $this->id;
  56.     }
  57.     public function getName(): ?string
  58.     {
  59.         return $this->name;
  60.     }
  61.     public function setName(string $name): self
  62.     {
  63.         $this->name $name;
  64.         return $this;
  65.     }
  66.     public function getSku(): ?string
  67.     {
  68.         return $this->sku;
  69.     }
  70.     public function setSku(string $sku): self
  71.     {
  72.         $this->sku $sku;
  73.         return $this;
  74.     }
  75.     public function getDescription(): ?string
  76.     {
  77.         return $this->description;
  78.     }
  79.     public function setDescription(string $description): self
  80.     {
  81.         $this->description $description;
  82.         return $this;
  83.     }
  84.     public function getShortDescription(): ?string
  85.     {
  86.         return $this->shortDescription;
  87.     }
  88.     public function setShortDescription(string $shortDescription): self
  89.     {
  90.         $this->shortDescription $shortDescription;
  91.         return $this;
  92.     }
  93.     public function getMetaTitle(): ?string
  94.     {
  95.         return $this->metaTitle;
  96.     }
  97.     public function setMetaTitle(string $metaTitle): self
  98.     {
  99.         $this->metaTitle $metaTitle;
  100.         return $this;
  101.     }
  102.     public function getMetaDescription(): ?string
  103.     {
  104.         return $this->metaDescription;
  105.     }
  106.     public function setMetaDescription(string $metaDescription): self
  107.     {
  108.         $this->metaDescription $metaDescription;
  109.         return $this;
  110.     }
  111.     public function getCategory(): ?int
  112.     {
  113.         return $this->category;
  114.     }
  115.     public function setCategory(int $category): self
  116.     {
  117.         $this->category $category;
  118.         return $this;
  119.     }
  120.     public function getImage(): ?string
  121.     {
  122.         return $this->image;
  123.     }
  124.     public function setImage(string $image): self
  125.     {
  126.         $this->image $image;
  127.         return $this;
  128.     }
  129.     public function getTva(): ?string
  130.     {
  131.         return $this->tva;
  132.     }
  133.     public function setTva(string $tva): self
  134.     {
  135.         $this->tva $tva;
  136.         return $this;
  137.     }
  138.     public function getUrl(): ?string
  139.     {
  140.         return $this->url;
  141.     }
  142.     public function setUrl(string $url): self
  143.     {
  144.         $this->url $url;
  145.         return $this;
  146.     }
  147.     /**
  148.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  149.      * of 'UploadedFile' is injected into this setter to trigger the update. If this
  150.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  151.      * must be able to accept an instance of 'File' as the bundle will inject one here
  152.      * during Doctrine hydration.
  153.      *
  154.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
  155.      */
  156.     public function setImageFile(?File $imageFile null): void
  157.     {
  158.         $this->imageFile $imageFile;
  159.         if (null !== $imageFile) {
  160.             // It is required that at least one field changes if you are using doctrine
  161.             // otherwise the event listeners won't be called and the file is lost
  162.             $this->updatedAt = new \DateTimeImmutable();
  163.         }
  164.     }
  165.     public function getImageFile(): ?File
  166.     {
  167.         return $this->imageFile;
  168.     }
  169.     public function getNomInitial(): ?string
  170.     {
  171.         return $this->nomInitial;
  172.     }
  173.     public function setNomInitial(string $nomInitialnull): self
  174.     {
  175.         $this->nomInitial $nomInitial;
  176.         return $this;
  177.     }
  178.     public function getNotes(): ?string
  179.     {
  180.         return $this->notes;
  181.     }
  182.     public function setNotes(?string $notes): self
  183.     {
  184.         $this->notes $notes;
  185.         return $this;
  186.     }
  187. }