src/Entity/Article.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ArticleRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\HttpFoundation\File\File;
  8. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  9. #[ORM\Entity(repositoryClassArticleRepository::class)]
  10. /**
  11.  * @ORM\Entity(repositoryClass=ArticleRepository::class)
  12.  * @Vich\Uploadable
  13.  */
  14. class Article
  15. {
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column(type'integer')]
  19.     private $id;
  20.     #[ORM\Column(type'string'length255)]
  21.     private $name;
  22.     #[ORM\Column(type'string'length255nullabletrue)]
  23.     private $description;
  24.     #[ORM\Column(type'integer')]
  25.     private $quantity;
  26.     #[ORM\Column(type'integer')]
  27.     private $warnining;
  28.     #[ORM\ManyToOne(targetEntityCategory::class, inversedBy'articles')]
  29.     private $category;
  30.     #[ORM\ManyToOne(targetEntityShop::class, inversedBy'articles')]
  31.     private $shop;
  32.     #[ORM\Column(type'string'length255nullabletrue)]
  33.     private $image;
  34.     /**
  35.      * @Vich\UploadableField(mapping="products_image", fileNameProperty="image")
  36.      * @var File
  37.      */
  38.     private $imageFile;
  39.     #[ORM\Column(type'datetime')]
  40.     private $updatedAt;
  41.     #[ORM\OneToMany(mappedBy'article'targetEntityEvolution::class)]
  42.     private $evolutions;
  43.     public function __construct()
  44.     {
  45.         $this->evolutions = new ArrayCollection();
  46.     }
  47.     public function getId(): ?int
  48.     {
  49.         return $this->id;
  50.     }
  51.     public function getName(): ?string
  52.     {
  53.         return $this->name;
  54.     }
  55.     public function setName(string $name): self
  56.     {
  57.         $this->name $name;
  58.         return $this;
  59.     }
  60.     public function getDescription(): ?string
  61.     {
  62.         return $this->description;
  63.     }
  64.     public function setDescription(?string $description): self
  65.     {
  66.         $this->description $description;
  67.         return $this;
  68.     }
  69.     public function getQuantity(): ?int
  70.     {
  71.         return $this->quantity;
  72.     }
  73.     public function setQuantity(int $quantity): self
  74.     {
  75.         $this->quantity $quantity;
  76.         return $this;
  77.     }
  78.     public function getWarnining(): ?int
  79.     {
  80.         return $this->warnining;
  81.     }
  82.     public function setWarnining(int $warnining): self
  83.     {
  84.         $this->warnining $warnining;
  85.         return $this;
  86.     }
  87.     public function getCategory(): ?Category
  88.     {
  89.         return $this->category;
  90.     }
  91.     public function setCategory(?Category $category): self
  92.     {
  93.         $this->category $category;
  94.         return $this;
  95.     }
  96.     public function getShop(): ?Shop
  97.     {
  98.         return $this->shop;
  99.     }
  100.     public function setShop(?Shop $shop): self
  101.     {
  102.         $this->shop $shop;
  103.         return $this;
  104.     }
  105.     public function setImageFile(File $image null)
  106.     {
  107.         $this->imageFile $image;
  108.         // VERY IMPORTANT:
  109.         // It is required that at least one field changes if you are using Doctrine,
  110.         // otherwise the event listeners won't be called and the file is lost
  111.         if ($image) {
  112.             // if 'updatedAt' is not defined in your entity, use another property
  113.             $this->updatedAt = new \DateTime('now');
  114.         }
  115.     }
  116.     public function getImageFile()
  117.     {
  118.         return $this->imageFile;
  119.     }
  120.     public function setImage($image)
  121.     {
  122.         $this->image $image;
  123.     }
  124.     public function getImage()
  125.     {
  126.         return $this->image;
  127.     }
  128.     /**
  129.      * @return Collection<int, Evolution>
  130.      */
  131.     public function getEvolutions(): Collection
  132.     {
  133.         return $this->evolutions;
  134.     }
  135.     public function addEvolution(Evolution $evolution): self
  136.     {
  137.         if (!$this->evolutions->contains($evolution)) {
  138.             $this->evolutions[] = $evolution;
  139.             $evolution->setArticle($this);
  140.         }
  141.         return $this;
  142.     }
  143.     public function removeEvolution(Evolution $evolution): self
  144.     {
  145.         if ($this->evolutions->removeElement($evolution)) {
  146.             // set the owning side to null (unless already changed)
  147.             if ($evolution->getArticle() === $this) {
  148.                 $evolution->setArticle(null);
  149.             }
  150.         }
  151.         return $this;
  152.     }
  153. }