<?phpnamespace App\Entity;use App\Repository\ChatFormationRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: ChatFormationRepository::class)]class ChatFormation{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\Column(type: Types::TEXT)] private ?string $message = null; #[ORM\Column(type: Types::DATETIME_MUTABLE)] private ?\DateTimeInterface $createdAt = null; #[ORM\Column(nullable: true)] private ?bool $isRead = false; /** * 'student' | 'admin' */ #[ORM\Column(length: 20)] private ?string $senderRole = null; #[ORM\ManyToOne(inversedBy: 'chatFormations')] private ?User $sender = null; #[ORM\ManyToOne(inversedBy: 'chatFormations')] private ?FormationElearning $formation = null; #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'chatFormations')] private ?self $parentMessage = null; #[ORM\OneToMany(mappedBy: 'parentMessage', targetEntity: self::class)] private Collection $chatFormations; public function __construct() { $this->chatFormations = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getMessage(): ?string { return $this->message; } public function setMessage(string $message): self { $this->message = $message; return $this; } public function getCreatedAt(): ?\DateTimeInterface { return $this->createdAt; } public function setCreatedAt(\DateTimeInterface $createdAt): self { $this->createdAt = $createdAt; return $this; } public function isRead(): ?bool { return $this->isRead; } public function setIsRead(?bool $isRead): self { $this->isRead = $isRead; return $this; } public function getSenderRole(): ?string { return $this->senderRole; } public function setSenderRole(string $senderRole): self { $this->senderRole = $senderRole; return $this; } public function getSender(): ?User { return $this->sender; } public function setSender(?User $sender): self { $this->sender = $sender; return $this; } public function getFormation(): ?FormationElearning { return $this->formation; } public function setFormation(?FormationElearning $formation): self { $this->formation = $formation; return $this; } public function getParentMessage(): ?self { return $this->parentMessage; } public function setParentMessage(?self $parentMessage): self { $this->parentMessage = $parentMessage; return $this; } /** * @return Collection<int, self> */ public function getChatFormations(): Collection { return $this->chatFormations; } public function addChatFormation(self $chatFormation): self { if (!$this->chatFormations->contains($chatFormation)) { $this->chatFormations->add($chatFormation); $chatFormation->setParentMessage($this); } return $this; } public function removeChatFormation(self $chatFormation): self { if ($this->chatFormations->removeElement($chatFormation)) { // set the owning side to null (unless already changed) if ($chatFormation->getParentMessage() === $this) { $chatFormation->setParentMessage(null); } } return $this; }}