src/Entity/Product.php line 14

  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 Gedmo\Mapping\Annotation as Gedmo;
  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 $quality null;
  19.     #[ORM\Column]
  20.     private ?int $code null;
  21.     #[ORM\Column]
  22.     private ?float $price null;
  23.     #[ORM\Column(length10)]
  24.     private ?string $currency null;
  25.     #[ORM\Column]
  26.     private ?int $min null;
  27.     #[ORM\Column(nullabletrue)]
  28.     private ?bool $actif null;
  29.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  30.     private ?string $description 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.     private ?File $imageFile null;
  34.     #[ORM\Column(length255nullabletrue)]
  35.     private ?string $image null;
  36.     #[ORM\Column(nullabletrue)]
  37.     private ?int $discount null;
  38.     #[ORM\ManyToOne(inversedBy'products')]
  39.     private ?Category $category null;
  40.     #[ORM\Column(length255,nullabletrue)]
  41.     private ?string $nomInitial null;
  42.     #[Gedmo\Slug(fields: ['quality'])]
  43.     #[ORM\Column(length255,uniquetrue)]
  44.     private ?string $slug null;
  45.     #[ORM\Column(length255nullabletrue)]
  46.     private ?string $description_url null;
  47.     public function __construct()
  48.     {
  49.         $this->createdAt = new \DateTimeImmutable('now');
  50.     }
  51.     public function getId(): ?int
  52.     {
  53.         return $this->id;
  54.     }
  55.     public function getName(): ?string
  56.     {
  57.         return $this->name;
  58.     }
  59.     public function setName(string $name): self
  60.     {
  61.         $this->name $name;
  62.         return $this;
  63.     }
  64.     public function getQuality(): ?string
  65.     {
  66.         return $this->quality;
  67.     }
  68.     public function setQuality(string $quality): self
  69.     {
  70.         $this->quality $quality;
  71.         return $this;
  72.     }
  73.     public function getCode(): ?int
  74.     {
  75.         return $this->code;
  76.     }
  77.     public function setCode(int $code): self
  78.     {
  79.         $this->code $code;
  80.         return $this;
  81.     }
  82.     public function getPrice(): ?float
  83.     {
  84.         return $this->price;
  85.     }
  86.     public function setPrice(float $price): self
  87.     {
  88.         $this->price $price;
  89.         return $this;
  90.     }
  91.     public function getCurrency(): ?string
  92.     {
  93.         return $this->currency;
  94.     }
  95.     public function setCurrency(string $currency): self
  96.     {
  97.         $this->currency $currency;
  98.         return $this;
  99.     }
  100.     public function getMin(): ?int
  101.     {
  102.         return $this->min;
  103.     }
  104.     public function setMin(int $min): self
  105.     {
  106.         $this->min $min;
  107.         return $this;
  108.     }
  109.     public function isActif(): ?bool
  110.     {
  111.         return $this->actif;
  112.     }
  113.     public function getDescription(): ?string
  114.     {
  115.         return $this->description;
  116.     }
  117.     public function setDescription(?string $description): self
  118.     {
  119.         $this->description $description;
  120.         return $this;
  121.     }
  122.     public function getImage(): ?string
  123.     {
  124.         return $this->image;
  125.     }
  126.     public function setImage(?string $image): self
  127.     {
  128.         $this->image $image;
  129.         return $this;
  130.     }
  131.     public function getDiscount(): ?int
  132.     {
  133.         return $this->discount;
  134.     }
  135.     public function setDiscount(?int $discount): self
  136.     {
  137.         $this->discount $discount;
  138.         return $this;
  139.     }
  140.     public function getCategory(): ?Category
  141.     {
  142.         return $this->category;
  143.     }
  144.     public function setCategory(?Category $category): self
  145.     {
  146.         $this->category $category;
  147.         return $this;
  148.     }
  149.     /**
  150.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  151.      * of 'UploadedFile' is injected into this setter to trigger the update. If this
  152.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  153.      * must be able to accept an instance of 'File' as the bundle will inject one here
  154.      * during Doctrine hydration.
  155.      *
  156.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
  157.      */
  158.     public function setImageFile(?File $imageFile null): void
  159.     {
  160.         $this->imageFile $imageFile;
  161.         if (null !== $imageFile) {
  162.             // It is required that at least one field changes if you are using doctrine
  163.             // otherwise the event listeners won't be called and the file is lost
  164.             $this->updatedAt = new \DateTimeImmutable();
  165.         }
  166.     }
  167.     public function getImageFile(): ?File
  168.     {
  169.         return $this->imageFile;
  170.     }
  171.     public function getNomInitial(): ?string
  172.     {
  173.         return $this->nomInitial;
  174.     }
  175.     public function setNomInitial(string $nomInitialnull): self
  176.     {
  177.         $this->nomInitial $nomInitial;
  178.         return $this;
  179.     }
  180.     public function getSlug(): ?string
  181.     {
  182.         return $this->slug;
  183.     }
  184.     public function getDescriptionUrl(): ?string
  185.     {
  186.         return $this->description_url;
  187.     }
  188.     public function setDescriptionUrl(?string $description_url): self
  189.     {
  190.         $this->description_url $description_url;
  191.         return $this;
  192.     }
  193. }