<?php
namespace App\Entity;
use App\Repository\PipelineMajWebMessageRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: PipelineMajWebMessageRepository::class)]
class PipelineMajWebMessage
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private ?int $id = null;
#[ORM\ManyToOne(targetEntity: PipelineMajWeb::class, inversedBy: 'messages')]
#[ORM\JoinColumn(nullable: false)]
private ?PipelineMajWeb $pipelineMajWeb = null;
#[ORM\Column(type: 'string', length: 20)]
private string $authorType = 'client'; // 'client'|'admin'
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $authorEmail = null;
#[ORM\Column(type: 'text')]
private string $message = '';
#[ORM\Column(type: 'datetime_immutable')]
private \DateTimeImmutable $createdAt;
#[ORM\OneToMany(mappedBy: 'message', targetEntity: PipelineMajWebAttachment::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
private Collection $attachments;
public function __construct()
{
$this->createdAt = new \DateTimeImmutable();
$this->attachments = new ArrayCollection();
}
public function getId(): ?int { return $this->id; }
public function getPipelineMajWeb(): ?PipelineMajWeb { return $this->pipelineMajWeb; }
public function setPipelineMajWeb(?PipelineMajWeb $pipelineMajWeb): self { $this->pipelineMajWeb = $pipelineMajWeb; return $this; }
public function getAuthorType(): string { return $this->authorType; }
public function setAuthorType(string $authorType): self { $this->authorType = $authorType; return $this; }
public function getAuthorEmail(): ?string { return $this->authorEmail; }
public function setAuthorEmail(?string $authorEmail): self { $this->authorEmail = $authorEmail; return $this; }
public function getMessage(): string { return $this->message; }
public function setMessage(string $message): self { $this->message = $message; return $this; }
public function getCreatedAt(): \DateTimeImmutable { return $this->createdAt; }
/** @return Collection<int, PipelineMajWebAttachment> */
public function getAttachments(): Collection { return $this->attachments; }
public function addAttachment(PipelineMajWebAttachment $attachment): self
{
if (!$this->attachments->contains($attachment)) {
$this->attachments[] = $attachment;
$attachment->setMessage($this);
}
return $this;
}
}