<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\ProductRepository;
use Doctrine\ORM\Mapping\InheritanceType;
use Doctrine\ORM\Mapping\DiscriminatorMap;
use Doctrine\ORM\Mapping\DiscriminatorColumn;
/**
* @ORM\Entity(repositoryClass=ProductRepository::class)
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorColumn(name="category", type="integer")
* @ORM\DiscriminatorMap({
* "1" = "Vinyl",
* "2" = "Cd",
* "3" = "Accessory"
* })
*/
abstract class Product
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
protected $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $ref;
/**
* @ORM\Column(type="string", length=255)
*/
private $designation;
/**
* @ORM\ManyToOne(targetEntity=Category::class, inversedBy="products")
* @ORM\JoinColumn(nullable=false)
*/
private $category;
/**
* @ORM\Column(type="datetime_immutable")
*/
private $createdAt;
/**
* @ORM\Column(type="float")
*/
private $price;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
private $updatedAt;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $promo;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $description;
/**
* @ORM\Column(type="string", length=100, unique=true)
*/
private $slug;
/**
* @ORM\Column(type="smallint", nullable=true)
*/
private $quantity;
/**
* @ORM\ManyToMany(targetEntity=Promote::class, inversedBy="products")
*/
private $promotes;
/**
* @ORM\OneToMany(targetEntity=Detail::class, mappedBy="product")
*/
private $orders;
/**
* @ORM\Column(type="smallint", nullable=true)
*/
private $weight;
public function __construct()
{
$this->promotes = new ArrayCollection();
$this->orders = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getRef(): ?string
{
return $this->ref;
}
public function setRef(string $ref): self
{
$this->ref = $ref;
return $this;
}
public function getDesignation(): ?string
{
return $this->designation;
}
public function setDesignation(string $designation): self
{
$this->designation = $designation;
return $this;
}
public function getCategory(): ?Category
{
return $this->category;
}
public function setCategory(?Category $category): self
{
$this->category = $category;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getPrice(): ?float
{
return $this->price;
}
public function setPrice(float $price): self
{
$this->price = $price;
return $this;
}
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getPromo(): ?float
{
return $this->promo;
}
public function setPromo(?float $promo): self
{
$this->promo = $promo;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getQuantity(): ?int
{
return $this->quantity;
}
public function setQuantity(?int $quantity): self
{
$this->quantity = $quantity;
return $this;
}
/**
* @return Collection|Promote[]
*/
public function getPromotes(): ?Collection
{
return $this->promotes;
}
public function addPromote(Promote $promote): self
{
if (!$this->promotes) {
$this->promotes = new ArrayCollection();
}
if (!$this->promotes->contains($promote)) {
$this->promotes[] = $promote;
}
return $this;
}
public function removePromote(Promote $promote): self
{
$this->promotes->removeElement($promote);
return $this;
}
/**
* @return Collection
*/
public function getOrders(): Collection
{
return $this->orders;
}
public function addOrder(Detail $order): self
{
if (!$this->orders->contains($order)) {
$this->orders[] = $order;
$order->setProduct($this);
}
return $this;
}
public function removeOrder(Detail $order): self
{
if ($this->orders->removeElement($order)) {
// set the owning side to null (unless already changed)
if ($order->getProduct() === $this) {
$order->setProduct(null);
}
}
return $this;
}
public function getWeight(): ?int
{
return $this->weight;
}
public function setWeight(?int $weight): self
{
$this->weight = $weight;
return $this;
}
}