<?php
namespace App\Entity;
use App\Traits\UuidEntityTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity()
* @ORM\Table(indexes={
* @ORM\Index(name="idx_vin_created_at", columns={"created_at"}),
* @ORM\Index(name="idx_vin_vin", columns={"vin"}
* )})
*/
class Vin
{
use UuidEntityTrait;
/**
* @ORM\Column(type="string", length=20, unique=true)
*/
#[Groups(['index', 'orderHistory'])]
private string $vin;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
#[Groups(['index'])]
private ?string $region = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
#[Groups(['index'])]
private ?string $country = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
#[Groups(['index'])]
private ?string $model = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
#[Groups(['index'])]
private ?string $fullModel = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
#[Groups(['index'])]
private ?string $manufacturer = null;
/**
* @ORM\Column(type="integer", nullable=true)
*/
#[Groups(['index'])]
private ?int $year = null;
/**
* @ORM\Column(type="boolean")
*/
#[Groups(['index'])]
private bool $ready = false;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
#[Groups(['index'])]
private ?bool $checkSum = null;
/**
* @ORM\ManyToMany(targetEntity=ReportType::class)
*
* @var Collection<int, ReportType>
*/
#[Groups(['index'])]
private Collection $reportTypes;
/**
* @ORM\OneToMany(targetEntity=Order::class, mappedBy="vin")
*/
#[Groups(['order'])]
private Collection $orders;
/**
* @ORM\Column(type="datetime", nullable=true, options={"default": "CURRENT_TIMESTAMP"})
*/
#[Groups(['order'])]
private ?\DateTimeInterface $createdAt = null;
public function __construct()
{
$this->reportTypes = new ArrayCollection();
$this->orders = new ArrayCollection();
}
public function getVin(): string
{
return $this->vin;
}
public function setVin(string $vin): self
{
$this->vin = $vin;
return $this;
}
public function getRegion(): ?string
{
return $this->region;
}
public function setRegion(?string $region): self
{
$this->region = $region;
return $this;
}
public function getCountry(): ?string
{
return $this->country;
}
public function setCountry(?string $country): self
{
$this->country = $country;
return $this;
}
public function getModel(): ?string
{
return $this->model;
}
public function setModel(?string $model): Vin
{
$this->model = $model;
return $this;
}
public function getFullModel(): ?string
{
return $this->fullModel;
}
public function setFullModel(?string $fullModel): Vin
{
$this->fullModel = $fullModel;
return $this;
}
public function getManufacturer(): ?string
{
return $this->manufacturer;
}
public function setManufacturer(?string $manufacturer): Vin
{
$this->manufacturer = $manufacturer;
return $this;
}
public function getYear(): ?int
{
return $this->year;
}
public function setYear(?int $year): self
{
$this->year = $year;
return $this;
}
public function isReady(): ?bool
{
return $this->ready;
}
public function setReady(bool $ready): Vin
{
$this->ready = $ready;
return $this;
}
public function isCheckSum(): ?bool
{
return $this->checkSum;
}
public function setCheckSum(?bool $checkSum): Vin
{
$this->checkSum = $checkSum;
return $this;
}
public function getReportTypes(): Collection
{
return $this->reportTypes;
}
public function addReportType(ReportType $reportType): self
{
if (!$this->containsReportType($reportType)) {
$this->reportTypes[] = $reportType;
}
return $this;
}
public function removeReportType(ReportType $reportType): self
{
$this->reportTypes->removeElement($reportType);
return $this;
}
public function getOrders(): Collection
{
return $this->orders;
}
public function addOrder(Order $order): self
{
if (!$this->orders->contains($order)) {
$this->orders[] = $order;
$order->setVin($this);
}
return $this;
}
public function removeOrder(Order $order): self
{
if ($this->orders->removeElement($order)) {
// set the owning side to null (unless already changed)
if ($order->getVin() === $this) {
$order->setVin(null);
}
}
return $this;
}
public function containsReportType(ReportType $reportType): bool
{
foreach ($this->getReportTypes() as $rt) {
if (!$rt instanceof ReportType || ($rtId = $rt->getId()) === null) {
continue;
}
if ($rtId->equals($reportType->getId())) {
return true;
}
}
return false;
}
public function __toString(): string
{
return $this->vin;
}
}