<?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)]
#[ORM\Index(columns: ['ean', 'project_id'], name: 'product_ean_project_idx')]
class Product
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 500, nullable: true)]
private ?string $name = null;
#[ORM\Column]
private ?bool $inCatalog = null;
#[ORM\Column(length: 50)]
private ?string $ean = null;
#[ORM\ManyToOne(targetEntity: Project::class)]
private ?Project $project = null;
#[ORM\ManyToOne(targetEntity: Brand::class, cascade: ['persist'])]
#[ORM\JoinColumn(nullable: true)]
private ?Brand $brand = null;
#[ORM\Column]
private ?\DateTime $lastUpdate = null;
#[ORM\OneToMany(mappedBy: 'product', targetEntity: Record::class)]
private Collection $records;
#[ORM\Column(length: 255, nullable: true)]
private ?string $photo = null;
#[ORM\Column(type: Types::BLOB, nullable: true)]
private $photomini;
public function __construct()
{
$this->records = new ArrayCollection();
$this->name = '';
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getProject(): ?Project
{
return $this->project;
}
public function setProject(?Project $project): static
{
$this->project = $project;
return $this;
}
public function getBrand(): ?Brand
{
return $this->brand;
}
public function setBrand(?Brand $brand): static
{
$this->brand = $brand;
return $this;
}
public function isInCatalog(): ?bool
{
return $this->inCatalog;
}
public function setInCatalog(bool $inCatalog): static
{
$this->inCatalog = $inCatalog;
return $this;
}
public function getEan(): ?string
{
return $this->ean;
}
public function setEan(string $ean): static
{
$this->ean = $ean;
return $this;
}
public function getLastUpdate(): ?\DateTimeInterface
{
return $this->lastUpdate;
}
public function setLastUpdate(\DateTime $lastUpdate): static
{
$this->lastUpdate = $lastUpdate;
return $this;
}
public function getId(): ?int
{
return $this->id;
}
/**
* @return Collection<int, Record>
*/
public function getRecords(): Collection
{
return $this->records;
}
public function addRecord(Record $record): static
{
if (!$this->records->contains($record)) {
$this->records->add($record);
$record->setProduct($this);
}
return $this;
}
public function removeRecord(Record $record): static
{
if ($this->records->removeElement($record)) {
// set the owning side to null (unless already changed)
if ($record->getProduct() === $this) {
$record->setProduct(null);
}
}
return $this;
}
public function getPhoto(): ?string
{
return $this->photo;
}
public function setPhoto(?string $photo): static
{
$this->photo = $photo;
return $this;
}
public function getPhotomini()
{
return $this->photomini;
}
public function setPhotomini($photomini): static
{
$this->photomini = $photomini;
return $this;
}
}