<?php
namespace App\Entity;
use App\Entity\Product\Product;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* Packing
*
* @ORM\Table(name="packing")
* @ORM\Entity()
*/
class Packing
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="float")
*/
private $length;
/**
* @ORM\Column(type="float")
*/
private $width;
/**
* @ORM\Column(type="float")
*/
private $height;
/**
* @ORM\Column(type="float")
*/
private $weight;
/**
* @ORM\OneToMany(targetEntity=Product::class, mappedBy="packing")
*/
private $products;
public function __construct()
{
$this->products = new ArrayCollection();
}
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 getLength(): ?float
{
return $this->length;
}
public function setLength(float $length): self
{
$this->length = $length;
return $this;
}
public function getWidth(): ?float
{
return $this->width;
}
public function setWidth(float $width): self
{
$this->width = $width;
return $this;
}
public function getHeight(): ?float
{
return $this->height;
}
public function setHeight(float $height): self
{
$this->height = $height;
return $this;
}
public function __toString()
{
return "{$this->name} ({$this->length}x{$this->width}x{$this->height})x{$this->weight}Kg";
}
public function getWeight(): ?float
{
return $this->weight;
}
public function setWeight(float $weight): self
{
$this->weight = $weight;
return $this;
}
/**
* @return Collection<int, Product>
*/
public function getProducts(): Collection
{
return $this->products;
}
public function addProduct(Product $product): self
{
if (!$this->products->contains($product)) {
$this->products[] = $product;
$product->setPacking($this);
}
return $this;
}
public function removeProduct(Product $product): self
{
if ($this->products->removeElement($product)) {
// set the owning side to null (unless already changed)
if ($product->getPacking() === $this) {
$product->setPacking(null);
}
}
return $this;
}
}