<?php
namespace App\Entity;
use App\Repository\ReferenceRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass=ReferenceRepository::class)
*/
class Reference
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"brand_references", "stock_edit", "installation_edit"})
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"brand_references", "stock_edit"})
*/
private $name;
/**
* @ORM\ManyToOne(targetEntity=Brand::class, inversedBy="brand_references")
* @Groups({"installation_edit"})
*/
private $brand;
/**
* @ORM\OneToMany(targetEntity=Stock::class, mappedBy="reference")
*/
private $stocks;
/**
* @ORM\ManyToOne(targetEntity=Type::class)
*/
private $type;
/**
* @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
*/
private $actualPrice;
/**
* @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
*/
private $oldPrice;
/**
* @ORM\ManyToOne(targetEntity=Packaging::class, inversedBy="products")
*/
private $packaging;
public function __construct()
{
$this->stocks = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function setId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getBrand(): ?Brand
{
return $this->brand;
}
public function setBrand(?Brand $brand): self
{
$this->brand = $brand;
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->setReference($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->getReference() === $this) {
$stock->setReference(null);
}
}
return $this;
}
public function getType(): ?Type
{
return $this->type;
}
public function setType(?Type $type): self
{
$this->type = $type;
return $this;
}
public function getActualPrice(): ?string
{
return $this->actualPrice;
}
public function setActualPrice(?string $actualPrice): self
{
$this->actualPrice = $actualPrice;
return $this;
}
public function getOldPrice(): ?string
{
return $this->oldPrice;
}
public function setOldPrice(?string $oldPrice): self
{
$this->oldPrice = $oldPrice;
return $this;
}
public function getPackaging(): ?Packaging
{
return $this->packaging;
}
public function setPackaging(?Packaging $packaging): self
{
$this->packaging = $packaging;
return $this;
}
}