src/Entity/CRM/PromptTemplate.php line 15
<?phpnamespace App\Entity\CRM;use App\Enum\PromptCode;use App\Repository\CRM\PromptTemplateRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: PromptTemplateRepository::class)]#[ORM\Table(name: 'prompt_template')]#[ORM\UniqueConstraint(name: 'uniq_prompt_template_code_tenant', columns: ['code', 'tenant_id'])]class PromptTemplate{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\Column(length: 32, enumType: PromptCode::class)]private PromptCode $code;/*** NULL = prompt globalny (domyślny dla wszystkich oddziałów).* Konkretny Branch = override per oddział.*/#[ORM\ManyToOne]#[ORM\JoinColumn(name: 'tenant_id', nullable: true, onDelete: 'CASCADE')]private ?Branch $tenant = null;#[ORM\Column(length: 255)]private string $name;#[ORM\Column(type: Types::TEXT, nullable: true)]private ?string $description = null;#[ORM\ManyToOne(targetEntity: PromptTemplateVersion::class)]#[ORM\JoinColumn(name: 'current_version_id', nullable: true, onDelete: 'SET NULL')]private ?PromptTemplateVersion $currentVersion = null;#[ORM\OneToMany(mappedBy: 'template', targetEntity: PromptTemplateVersion::class, cascade: ['persist'], orphanRemoval: false)]#[ORM\OrderBy(['version' => 'DESC'])]private Collection $versions;#[ORM\Column(type: Types::DATETIME_MUTABLE)]private \DateTimeInterface $createdAt;#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]private ?\DateTimeInterface $updatedAt = null;public function __construct(PromptCode $code, string $name){$this->code = $code;$this->name = $name;$this->versions = new ArrayCollection();$this->createdAt = new \DateTimeImmutable();}public function __toString(): string{return sprintf('%s%s',$this->name,$this->tenant !== null ? sprintf(' [%s]', (string) $this->tenant) : ' [globalny]');}public function getId(): ?int{return $this->id;}public function getCode(): PromptCode{return $this->code;}public function setCode(PromptCode $code): static{$this->code = $code;return $this;}public function getTenant(): ?Branch{return $this->tenant;}public function setTenant(?Branch $tenant): static{$this->tenant = $tenant;return $this;}public function getName(): string{return $this->name;}public function setName(string $name): static{$this->name = $name;return $this;}public function getDescription(): ?string{return $this->description;}public function setDescription(?string $description): static{$this->description = $description;return $this;}public function getCurrentVersion(): ?PromptTemplateVersion{return $this->currentVersion;}public function setCurrentVersion(?PromptTemplateVersion $currentVersion): static{$this->currentVersion = $currentVersion;$this->updatedAt = new \DateTimeImmutable();return $this;}/*** @return Collection<int, PromptTemplateVersion>*/public function getVersions(): Collection{return $this->versions;}public function addVersion(PromptTemplateVersion $version): static{if (!$this->versions->contains($version)) {$this->versions->add($version);$version->setTemplate($this);}return $this;}public function getCreatedAt(): \DateTimeInterface{return $this->createdAt;}public function setCreatedAt(\DateTimeInterface $createdAt): static{$this->createdAt = $createdAt;return $this;}public function getUpdatedAt(): ?\DateTimeInterface{return $this->updatedAt;}public function setUpdatedAt(?\DateTimeInterface $updatedAt): static{$this->updatedAt = $updatedAt;return $this;}public function requiresSuperAdmin(): bool{return $this->code->requiresSuperAdmin();}}