<?php
namespace App\Entity;
use App\Entity\traits\base64Field;
use App\Entity\traits\Timestapable;
use App\Repository\ProductTypeRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ProductTypeRepository::class)]
class ProductType
{
use Timestapable;
use base64Field;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $description = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $image_url = null;
#[ORM\OneToMany(mappedBy: 'productType', targetEntity: Utensil::class)]
private Collection $utensils;
public function __construct()
{
$this->utensils = 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 getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getImageUrl(): ?string
{
return $this->image_url;
}
public function setImageUrl(?string $image_url): self
{
$this->image_url = $image_url;
return $this;
}
/**
* @return Collection<int, self>
*/
public function getProductTypes(): Collection
{
return $this->productTypes;
}
/**
* @return Collection<int, Utensil>
*/
public function getUtensils(): Collection
{
return $this->utensils;
}
public function addUtensil(Utensil $utensil): self
{
if (!$this->utensils->contains($utensil)) {
$this->utensils->add($utensil);
$utensil->setProductType($this);
}
return $this;
}
public function removeUtensil(Utensil $utensil): self
{
if ($this->utensils->removeElement($utensil)) {
// set the owning side to null (unless already changed)
if ($utensil->getProductType() === $this) {
$utensil->setProductType(null);
}
}
return $this;
}
}