<?php
namespace App\Entity;
use App\Repository\ProductRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
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 $name;
/**
* @ORM\ManyToOne(targetEntity=Color::class, inversedBy="products")
*/
private $color;
/**
* @ORM\ManyToOne(targetEntity=Grade::class, inversedBy="products")
*/
private $grade;
/**
* @ORM\ManyToOne(targetEntity=Keyboard::class, inversedBy="products")
*/
private $keyboard;
/**
* @ORM\ManyToOne(targetEntity=Capacity::class, inversedBy="products")
*/
private $capacity;
/**
* @ORM\ManyToOne(targetEntity=Model::class, inversedBy="products")
* @ORM\JoinColumn(nullable=false)
*/
private $model;
/**
* @ORM\Column(type="integer")
*/
private $qty;
/**
* @ORM\OneToMany(targetEntity=Stock::class, mappedBy="product")
*/
private $stocks;
/**
* @ORM\Column(type="string", length=32)
*/
private $sku;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $price;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $description;
/**
* @ORM\Column(type="string", length=16, nullable=true)
*/
private $channel;
public function __construct()
{
$this->stocks = new ArrayCollection();
}
public function __toString() {
return $this->getName();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getColor(): ?Color
{
return $this->color;
}
public function setColor(?Color $color): self
{
$this->color = $color;
return $this;
}
public function getGrade(): ?Grade
{
return $this->grade;
}
public function setGrade(?Grade $grade): self
{
$this->grade = $grade;
return $this;
}
public function getKeyboard(): ?Keyboard
{
return $this->keyboard;
}
public function setKeyboard(?Keyboard $keyboard): self
{
$this->keyboard = $keyboard;
return $this;
}
public function getCapacity(): ?Capacity
{
return $this->capacity;
}
public function setCapacity(?Capacity $capacity): self
{
$this->capacity = $capacity;
return $this;
}
public function getModel(): ?Model
{
return $this->model;
}
public function setModel(?Model $model): self
{
$this->model = $model;
return $this;
}
public function getQty(): ?int
{
return $this->qty;
}
public function setQty(int $qty): self
{
$this->qty = $qty;
return $this;
}
/**
* @return Collection<int, Stock>
*/
public function getStocks(): Collection
{
return $this->stocks;
}
public function getSku(): ?string
{
return $this->sku;
}
public function setSku(string $sku): self
{
$this->sku = $sku;
return $this;
}
public function getPrice(): ?int
{
return $this->price;
}
public function setPrice(?int $price): self
{
$this->price = $price;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getChannel(): ?string
{
return $this->channel;
}
public function setChannel(?string $channel): self
{
$this->channel = $channel;
return $this;
}
public function addStock(Stock $stock): static
{
if (!$this->stocks->contains($stock)) {
$this->stocks->add($stock);
$stock->setProduct($this);
}
return $this;
}
public function removeStock(Stock $stock): static
{
if ($this->stocks->removeElement($stock)) {
// set the owning side to null (unless already changed)
if ($stock->getProduct() === $this) {
$stock->setProduct(null);
}
}
return $this;
}
}