src/Entity/Article.php line 13

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. /**
  8.  * @ORM\Entity(repositoryClass=ArticleRepository::class)
  9.  */
  10. class Article
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=150)
  20.      */
  21.     private $label;
  22.     /**
  23.      * @ORM\Column(type="string", length=4096, nullable=true)
  24.      */
  25.     private $description;
  26.     /**
  27.      * @ORM\Column(type="string", length=100, nullable=true)
  28.      */
  29.     private $mainImage;
  30.     /**
  31.      * @ORM\Column(type="boolean")
  32.      */
  33.     private $is_new;
  34.     /**
  35.      * @ORM\ManyToOne(targetEntity=Category::class, inversedBy="articles")
  36.      * @ORM\JoinColumn(nullable=false)
  37.      */
  38.     private $category;
  39.     /**
  40.      * @ORM\ManyToOne(targetEntity=Section::class, inversedBy="articles")
  41.      * @ORM\JoinColumn(nullable=false)
  42.      */
  43.     private $section;
  44.     /**
  45.      * @ORM\ManyToOne(targetEntity=Brand::class, inversedBy="articles")
  46.      * @ORM\JoinColumn(nullable=true)
  47.      */
  48.     private $brand;
  49.     /**
  50.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="articles")
  51.      */
  52.     private $user;
  53.     /**
  54.      * @ORM\Column(type="integer", nullable=true)
  55.      */
  56.     private $price;
  57.     /**
  58.      * @var \DateTime
  59.      * @ORM\Column(name="creation_date", type="datetime")
  60.      */
  61.     private $creation_date;
  62.     /**
  63.      * @ORM\Column(type="boolean", nullable=true)
  64.      */
  65.     private $is_offer;
  66.     /**
  67.      * @ORM\OneToMany(targetEntity=ArticleImages::class, mappedBy="article", orphanRemoval=true)
  68.      */
  69.     private $articleImages;
  70.     public function __construct()
  71.     {
  72.         $this->articleImages = new ArrayCollection();
  73.     }
  74.     public function getId(): ?int
  75.     {
  76.         return $this->id;
  77.     }
  78.     public function getLabel(): ?string
  79.     {
  80.         return $this->label;
  81.     }
  82.     public function setLabel(string $label): self
  83.     {
  84.         $this->label $label;
  85.         return $this;
  86.     }
  87.     public function getDescription(): ?string
  88.     {
  89.         return $this->description;
  90.     }
  91.     public function setDescription(?string $description): self
  92.     {
  93.         $this->description $description;
  94.         return $this;
  95.     }
  96.     public function getMainImage(): ?string
  97.     {
  98.         return $this->mainImage;
  99.     }
  100.     public function setMainImage(?string $mainImage): self
  101.     {
  102.         $this->mainImage $mainImage;
  103.         return $this;
  104.     }
  105.     public function isIsNew(): ?bool
  106.     {
  107.         return $this->is_new;
  108.     }
  109.     public function setIsNew(bool $is_new): self
  110.     {
  111.         $this->is_new $is_new;
  112.         return $this;
  113.     }
  114.     public function getCategory(): ?Category
  115.     {
  116.         return $this->category;
  117.     }
  118.     public function setCategory(?Category $category): self
  119.     {
  120.         $this->category $category;
  121.         return $this;
  122.     }
  123.     public function getSection(): ?Section
  124.     {
  125.         return $this->section;
  126.     }
  127.     public function setSection(?Section $section): self
  128.     {
  129.         $this->section $section;
  130.         return $this;
  131.     }
  132.     public function getBrand(): ?Brand
  133.     {
  134.         return $this->brand;
  135.     }
  136.     public function setBrand(?Brand $brand): self
  137.     {
  138.         $this->brand $brand;
  139.         return $this;
  140.     }
  141.     public function getUser(): ?User
  142.     {
  143.         return $this->user;
  144.     }
  145.     public function setUser(?User $user): self
  146.     {
  147.         $this->user $user;
  148.         return $this;
  149.     }
  150.     public function getPrice(): ?int
  151.     {
  152.         return $this->price;
  153.     }
  154.     public function setPrice(?int $price): self
  155.     {
  156.         $this->price $price;
  157.         return $this;
  158.     }
  159.     /**
  160.      * @return \DateTime
  161.      */
  162.     public function getCreationDate(): \DateTime
  163.     {
  164.         return $this->creation_date;
  165.     }
  166.     /**
  167.      * @param \DateTime $creation_date
  168.      */
  169.     public function setCreationDate(\DateTime $creation_date): void
  170.     {
  171.         $this->creation_date $creation_date;
  172.     }
  173.     public function isIsOffer(): ?bool
  174.     {
  175.         return $this->is_offer;
  176.     }
  177.     public function setIsOffer(?bool $is_offer): self
  178.     {
  179.         $this->is_offer $is_offer;
  180.         return $this;
  181.     }
  182.     /**
  183.      * @return Collection<int, ArticleImages>
  184.      */
  185.     public function getArticleImages(): Collection
  186.     {
  187.         return $this->articleImages;
  188.     }
  189.     public function addArticleImage(ArticleImages $articleImage): self
  190.     {
  191.         if (!$this->articleImages->contains($articleImage)) {
  192.             $this->articleImages[] = $articleImage;
  193.             $articleImage->setArticle($this);
  194.         }
  195.         return $this;
  196.     }
  197.     public function removeArticleImage(ArticleImages $articleImage): self
  198.     {
  199.         if ($this->articleImages->removeElement($articleImage)) {
  200.             // set the owning side to null (unless already changed)
  201.             if ($articleImage->getArticle() === $this) {
  202.                 $articleImage->setArticle(null);
  203.             }
  204.         }
  205.         return $this;
  206.     }
  207. }