<?php
namespace App\Entity;
use App\Repository\PackagingRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=PackagingRepository::class)
*/
class Packaging
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\OneToMany(targetEntity=Reference::class, mappedBy="packaging")
*/
private $products;
public function __construct()
{
$this->products = new ArrayCollection();
}
public function __toString(): string
{
return $this->name;
}
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;
}
/**
* @return Collection<int, Reference>
*/
public function getProducts(): Collection
{
return $this->products;
}
public function addProduct(Reference $product): self
{
if (!$this->products->contains($product)) {
$this->products[] = $product;
$product->setPackaging($this);
}
return $this;
}
public function removeProduct(Reference $product): self
{
if ($this->products->removeElement($product)) {
// set the owning side to null (unless already changed)
if ($product->getPackaging() === $this) {
$product->setPackaging(null);
}
}
return $this;
}
}