<?php
namespace App\Entity\BC;
use App\Repository\BC\ImportLogRepository;
use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
#[ORM\Entity(repositoryClass: ImportLogRepository::class)]
#[ORM\HasLifecycleCallbacks]
#[ORM\Index(name: 'idx_item_no_created', columns: ['item_no', 'created_at'])]
class ImportLog
{
#[ORM\Id]
#[ORM\Column(type: 'string', length: 255)]
private string $id;
#[ORM\Column(type: 'string', length: 64)]
private string $itemNo;
#[ORM\Column(type: 'text')]
private string $itemData;
#[ORM\Column(type: 'datetime_immutable')]
private \DateTimeImmutable $createdAt;
public function __construct(string $itemNo, string $itemData)
{
$uuid = Uuid::uuid1();
$this->id = sprintf('%s_%s', $itemNo, $uuid->toString());
$this->itemNo = $itemNo;
$this->itemData = $itemData;
$this->createdAt = new \DateTimeImmutable();
}
public function getId(): string
{
return $this->id;
}
public function getUuid(): UuidInterface
{
$uuidPart = explode('_', $this->id)[1];
return Uuid::fromString($uuidPart);
}
public function getItemNo(): string
{
return $this->itemNo;
}
public function getItemData(): string
{
return $this->itemData;
}
public function getCreatedAt(): \DateTimeImmutable
{
return $this->createdAt;
}
}