src/Entity/BC/ImportLog.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity\BC;
  3. use App\Repository\BC\ImportLogRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Ramsey\Uuid\Uuid;
  6. use Ramsey\Uuid\UuidInterface;
  7. #[ORM\Entity(repositoryClassImportLogRepository::class)]
  8. #[ORM\HasLifecycleCallbacks]
  9. #[ORM\Index(name'idx_item_no_created'columns: ['item_no''created_at'])]
  10. class ImportLog
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\Column(type'string'length255)]
  14.     private string $id;
  15.     #[ORM\Column(type'string'length64)]
  16.     private string $itemNo;
  17.     #[ORM\Column(type'text')]
  18.     private string $itemData;
  19.     #[ORM\Column(type'datetime_immutable')]
  20.     private \DateTimeImmutable $createdAt;
  21.     public function __construct(string $itemNostring $itemData)
  22.     {
  23.         $uuid Uuid::uuid1();
  24.         $this->id sprintf('%s_%s'$itemNo$uuid->toString());
  25.         $this->itemNo $itemNo;
  26.         $this->itemData $itemData;
  27.         $this->createdAt = new \DateTimeImmutable();
  28.     }
  29.     public function getId(): string
  30.     {
  31.         return $this->id;
  32.     }
  33.     public function getUuid(): UuidInterface
  34.     {
  35.         $uuidPart explode('_'$this->id)[1];
  36.         return Uuid::fromString($uuidPart);
  37.     }
  38.     public function getItemNo(): string
  39.     {
  40.         return $this->itemNo;
  41.     }
  42.     public function getItemData(): string
  43.     {
  44.         return $this->itemData;
  45.     }
  46.     public function getCreatedAt(): \DateTimeImmutable
  47.     {
  48.         return $this->createdAt;
  49.     }
  50. }