<?php
namespace App\Entity;
use App\Traits\UuidEntityTrait;
use Doctrine\ORM\Mapping as ORM;
use App\Traits\TimestampableEntity;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity()
*/
class Report
{
use UuidEntityTrait;
use TimestampableEntity;
/**
* @ORM\ManyToOne(targetEntity=ReportType::class, fetch="EAGER")
* @ORM\JoinColumn(nullable=false)
*/
#[Groups(['index', 'orderHistory'])]
private ?ReportType $reportType;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $content = null;
/**
* @ORM\Column(type="decimal", precision=10, scale=2)
*/
#[Groups(['index'])]
private ?float $price;
/**
* @ORM\Column(type="boolean")
*/
#[Groups(['index', 'orderHistory'])]
private bool $loaded = false;
/**
* @ORM\Column(type="boolean")
*/
#[Groups(['index'])]
private bool $handled = false;
/**
* @ORM\ManyToOne (targetEntity=Order::class, inversedBy="reports", fetch="EAGER")
* @ORM\JoinColumn(name="order_id", referencedColumnName="id")
*/
private ?Order $order;
public function __toString(): string
{
return $this->getOrder()?->getId() . '_' .
$this->getOrder()?->getVin()?->getVin() . '_' .
$this->getReportType()?->getName() . '_' .
($this->getHandled() ? 'Handled' : 'NotHandled') . '_' .
($this->getLoaded() ? 'Loaded' : 'NotLoaded');
}
public function getReportType(): ?ReportType
{
return $this->reportType;
}
public function setReportType(?ReportType $reportType): self
{
$this->reportType = $reportType;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(?string $content): self
{
$this->content = $content;
return $this;
}
public function getPrice(): ?float
{
return $this->price;
}
public function setPrice(float $price): self
{
$this->price = $price;
return $this;
}
public function getHandled(): bool
{
return $this->handled;
}
public function setHandled(bool $handled): self
{
$this->handled = $handled;
return $this;
}
public function getLoaded(): bool
{
return $this->loaded;
}
public function setLoaded(bool $loaded): Report
{
$this->loaded = $loaded;
return $this;
}
public function getOrder(): ?Order
{
return $this->order;
}
public function setOrder(?Order $order): Report
{
$this->order = $order;
return $this;
}
public function getVin(): ?string
{
return $this->order?->getVin()?->getVin();
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->order?->getCreatedAt();
}
}