src/Entity/CRM/PromptTemplateVersion.php line 12

  1. <?php
  2. namespace App\Entity\CRM;
  3. use App\Repository\CRM\PromptTemplateVersionRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Entity(repositoryClassPromptTemplateVersionRepository::class)]
  7. #[ORM\Table(name'prompt_template_version')]
  8. #[ORM\UniqueConstraint(name'uniq_prompt_template_version'columns: ['template_id''version'])]
  9. class PromptTemplateVersion
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\ManyToOne(inversedBy'versions')]
  16.     #[ORM\JoinColumn(nullablefalseonDelete'CASCADE')]
  17.     private ?PromptTemplate $template null;
  18.     #[ORM\Column]
  19.     private int $version 1;
  20.     #[ORM\Column(typeTypes::TEXT)]
  21.     private string $content '';
  22.     #[ORM\Column(length64nullabletrue)]
  23.     private ?string $model null;
  24.     /**
  25.      * @var array<string, mixed>|null
  26.      */
  27.     #[ORM\Column(typeTypes::JSONnullabletrue)]
  28.     private ?array $parameters null;
  29.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  30.     private ?string $note null;
  31.     #[ORM\ManyToOne]
  32.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  33.     private ?Admin $createdBy null;
  34.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  35.     private \DateTimeInterface $createdAt;
  36.     #[ORM\Column]
  37.     private bool $active false;
  38.     public function __construct()
  39.     {
  40.         $this->createdAt = new \DateTimeImmutable();
  41.     }
  42.     public function __toString(): string
  43.     {
  44.         $tplName $this->template !== null $this->template->getName() : 'prompt';
  45.         return sprintf('%s v%d'$tplName$this->version);
  46.     }
  47.     public function getId(): ?int
  48.     {
  49.         return $this->id;
  50.     }
  51.     public function getTemplate(): ?PromptTemplate
  52.     {
  53.         return $this->template;
  54.     }
  55.     public function setTemplate(?PromptTemplate $template): static
  56.     {
  57.         $this->template $template;
  58.         return $this;
  59.     }
  60.     public function getVersion(): int
  61.     {
  62.         return $this->version;
  63.     }
  64.     public function setVersion(int $version): static
  65.     {
  66.         $this->version $version;
  67.         return $this;
  68.     }
  69.     public function getContent(): string
  70.     {
  71.         return $this->content;
  72.     }
  73.     public function setContent(string $content): static
  74.     {
  75.         $this->content $content;
  76.         return $this;
  77.     }
  78.     public function getModel(): ?string
  79.     {
  80.         return $this->model;
  81.     }
  82.     public function setModel(?string $model): static
  83.     {
  84.         $this->model $model;
  85.         return $this;
  86.     }
  87.     /**
  88.      * @return array<string, mixed>|null
  89.      */
  90.     public function getParameters(): ?array
  91.     {
  92.         return $this->parameters;
  93.     }
  94.     /**
  95.      * @param array<string, mixed>|null $parameters
  96.      */
  97.     public function setParameters(?array $parameters): static
  98.     {
  99.         $this->parameters $parameters;
  100.         return $this;
  101.     }
  102.     public function getNote(): ?string
  103.     {
  104.         return $this->note;
  105.     }
  106.     public function setNote(?string $note): static
  107.     {
  108.         $this->note $note;
  109.         return $this;
  110.     }
  111.     public function getCreatedBy(): ?Admin
  112.     {
  113.         return $this->createdBy;
  114.     }
  115.     public function setCreatedBy(?Admin $createdBy): static
  116.     {
  117.         $this->createdBy $createdBy;
  118.         return $this;
  119.     }
  120.     public function getCreatedAt(): \DateTimeInterface
  121.     {
  122.         return $this->createdAt;
  123.     }
  124.     public function setCreatedAt(\DateTimeInterface $createdAt): static
  125.     {
  126.         $this->createdAt $createdAt;
  127.         return $this;
  128.     }
  129.     public function isActive(): bool
  130.     {
  131.         return $this->active;
  132.     }
  133.     public function setActive(bool $active): static
  134.     {
  135.         $this->active $active;
  136.         return $this;
  137.     }
  138. }