<?php
namespace App\Entity;
use App\Repository\ProductRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=ProductRepository::class)
*/
class Product
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $label;
/**
* @ORM\Column(type="string", length=50)
*/
private $unit;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $expirationDelay;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $stockLimit;
/**
* @ORM\ManyToOne(targetEntity=Category::class, inversedBy="products")
* @ORM\JoinColumn(nullable=false)
*/
private $category;
/**
* @ORM\ManyToOne(targetEntity=SubCategory::class, inversedBy="products")
*/
private $subCategory;
/**
* @ORM\Column(type="datetime")
*/
private $creation_date;
/**
* @ORM\OneToMany(targetEntity=Stock::class, mappedBy="product", orphanRemoval=true)
*/
private $stocks;
/**
* @ORM\OneToMany(targetEntity=SaleItems::class, mappedBy="product")
*/
private $saleItems;
/**
* @ORM\OneToMany(targetEntity=DiscountProducts::class, mappedBy="product")
*/
private $discountedProducts;
/**
* @ORM\Column(type="boolean")
*/
private $shortcut;
/**
* @ORM\OneToMany(targetEntity=Notifications::class, mappedBy="product_id")
*/
private $notifications;
/**
* @ORM\Column(type="string", length=255)
*/
private $target;
/**
* @ORM\Column(type="boolean")
*/
private $isSynch;
/**
* @ORM\Column(type="boolean")
*/
private $deleted = 0;
public function __construct()
{
$this->stocks = new ArrayCollection();
$this->saleItems = new ArrayCollection();
$this->discountedProducts = new ArrayCollection();
$this->notifications = 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 getUnit(): ?string
{
return $this->unit;
}
public function setUnit(string $unit): self
{
$this->unit = $unit;
return $this;
}
public function getExpirationDelay(): ?int
{
return $this->expirationDelay;
}
public function setExpirationDelay(?int $expirationDelay): self
{
$this->expirationDelay = $expirationDelay;
return $this;
}
public function getStockLimit(): ?int
{
return $this->stockLimit;
}
public function setStockLimit(?int $stockLimit): self
{
$this->stockLimit = $stockLimit;
return $this;
}
public function getCategory(): ?Category
{
return $this->category;
}
public function setCategory(?Category $category): self
{
$this->category = $category;
return $this;
}
public function getSubCategory(): ?SubCategory
{
return $this->subCategory;
}
public function setSubCategory(?SubCategory $subCategory): self
{
$this->subCategory = $subCategory;
return $this;
}
public function getCreationDate(): ?\DateTimeInterface
{
return $this->creation_date;
}
public function setCreationDate(\DateTimeInterface $creation_date): self
{
$this->creation_date = $creation_date;
return $this;
}
/**
* @return Collection<int, Stock>
*/
public function getStocks(): Collection
{
return $this->stocks;
}
public function addStock(Stock $stock): self
{
if (!$this->stocks->contains($stock)) {
$this->stocks[] = $stock;
$stock->setProduct($this);
}
return $this;
}
public function removeStock(Stock $stock): self
{
if ($this->stocks->removeElement($stock)) {
// set the owning side to null (unless already changed)
if ($stock->getProduct() === $this) {
$stock->setProduct(null);
}
}
return $this;
}
/**
* @return Collection<int, SaleItems>
*/
public function getSaleItems(): Collection
{
return $this->saleItems;
}
public function addSaleItem(SaleItems $saleItem): self
{
if (!$this->saleItems->contains($saleItem)) {
$this->saleItems[] = $saleItem;
$saleItem->setProduct($this);
}
return $this;
}
public function removeSaleItem(SaleItems $saleItem): self
{
if ($this->saleItems->removeElement($saleItem)) {
// set the owning side to null (unless already changed)
if ($saleItem->getProduct() === $this) {
$saleItem->setProduct(null);
}
}
return $this;
}
/**
* @return Collection<int, DiscountProducts>
*/
public function getDiscountedProducts(): Collection
{
return $this->discountedProducts;
}
public function addDiscountedProduct(DiscountProducts $discountedProduct): self
{
if (!$this->discountedProducts->contains($discountedProduct)) {
$this->discountedProducts[] = $discountedProduct;
$discountedProduct->setProduct($this);
}
return $this;
}
public function removeDiscountedProduct(DiscountProducts $discountedProduct): self
{
if ($this->discountedProducts->removeElement($discountedProduct)) {
// set the owning side to null (unless already changed)
if ($discountedProduct->getProduct() === $this) {
$discountedProduct->setProduct(null);
}
}
return $this;
}
/**
* @return mixed
*/
public function getShortcut()
{
return $this->shortcut;
}
/**
* @param mixed $shortcut
*/
public function setShortcut($shortcut): void
{
$this->shortcut = $shortcut;
}
/**
* @return Collection<int, Notifications>
*/
public function getNotifications(): Collection
{
return $this->notifications;
}
public function addNotification(Notifications $notification): self
{
if (!$this->notifications->contains($notification)) {
$this->notifications[] = $notification;
$notification->setProductId($this);
}
return $this;
}
public function removeNotification(Notifications $notification): self
{
if ($this->notifications->removeElement($notification)) {
// set the owning side to null (unless already changed)
if ($notification->getProductId() === $this) {
$notification->setProductId(null);
}
}
return $this;
}
/**
* @return mixed
*/
public function getTarget()
{
return $this->target;
}
/**
* @param mixed $target
*/
public function setTarget($target): void
{
$this->target = $target;
}
/**
* @return mixed
*/
public function getisSynch()
{
return $this->isSynch;
}
/**
* @param mixed $isSynch
*/
public function setisSynch($isSynch): void
{
$this->isSynch = $isSynch;
}
/**
* @return mixed
*/
public function getDeleted()
{
return $this->deleted;
}
/**
* @param mixed $deleted
*/
public function setDeleted($deleted): void
{
$this->deleted = $deleted;
}
}