<?php
namespace App\Entity;
use App\Repository\ArticleRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=ArticleRepository::class)
*/
class Article
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=150)
*/
private $label;
/**
* @ORM\Column(type="string", length=4096, nullable=true)
*/
private $description;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $mainImage;
/**
* @ORM\Column(type="boolean")
*/
private $is_new;
/**
* @ORM\ManyToOne(targetEntity=Category::class, inversedBy="articles")
* @ORM\JoinColumn(nullable=false)
*/
private $category;
/**
* @ORM\ManyToOne(targetEntity=Section::class, inversedBy="articles")
* @ORM\JoinColumn(nullable=false)
*/
private $section;
/**
* @ORM\ManyToOne(targetEntity=Brand::class, inversedBy="articles")
* @ORM\JoinColumn(nullable=true)
*/
private $brand;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="articles")
*/
private $user;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $price;
/**
* @var \DateTime
* @ORM\Column(name="creation_date", type="datetime")
*/
private $creation_date;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $is_offer;
/**
* @ORM\OneToMany(targetEntity=ArticleImages::class, mappedBy="article", orphanRemoval=true)
*/
private $articleImages;
public function __construct()
{
$this->articleImages = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(string $label): self
{
$this->label = $label;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getMainImage(): ?string
{
return $this->mainImage;
}
public function setMainImage(?string $mainImage): self
{
$this->mainImage = $mainImage;
return $this;
}
public function isIsNew(): ?bool
{
return $this->is_new;
}
public function setIsNew(bool $is_new): self
{
$this->is_new = $is_new;
return $this;
}
public function getCategory(): ?Category
{
return $this->category;
}
public function setCategory(?Category $category): self
{
$this->category = $category;
return $this;
}
public function getSection(): ?Section
{
return $this->section;
}
public function setSection(?Section $section): self
{
$this->section = $section;
return $this;
}
public function getBrand(): ?Brand
{
return $this->brand;
}
public function setBrand(?Brand $brand): self
{
$this->brand = $brand;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getPrice(): ?int
{
return $this->price;
}
public function setPrice(?int $price): self
{
$this->price = $price;
return $this;
}
/**
* @return \DateTime
*/
public function getCreationDate(): \DateTime
{
return $this->creation_date;
}
/**
* @param \DateTime $creation_date
*/
public function setCreationDate(\DateTime $creation_date): void
{
$this->creation_date = $creation_date;
}
public function isIsOffer(): ?bool
{
return $this->is_offer;
}
public function setIsOffer(?bool $is_offer): self
{
$this->is_offer = $is_offer;
return $this;
}
/**
* @return Collection<int, ArticleImages>
*/
public function getArticleImages(): Collection
{
return $this->articleImages;
}
public function addArticleImage(ArticleImages $articleImage): self
{
if (!$this->articleImages->contains($articleImage)) {
$this->articleImages[] = $articleImage;
$articleImage->setArticle($this);
}
return $this;
}
public function removeArticleImage(ArticleImages $articleImage): self
{
if ($this->articleImages->removeElement($articleImage)) {
// set the owning side to null (unless already changed)
if ($articleImage->getArticle() === $this) {
$articleImage->setArticle(null);
}
}
return $this;
}
}