src/Entity/ChatFormation.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ChatFormationRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassChatFormationRepository::class)]
  9. class ChatFormation
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\Column(typeTypes::TEXT)]
  16.     private ?string $message null;
  17.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  18.     private ?\DateTimeInterface $createdAt null;
  19.     #[ORM\Column(nullabletrue)]
  20.     private ?bool $isRead false;
  21.     /**
  22.      * 'student' | 'admin'
  23.      */
  24.     #[ORM\Column(length20)]
  25.     private ?string $senderRole null;
  26.     #[ORM\ManyToOne(inversedBy'chatFormations')]
  27.     private ?User $sender null;
  28.     #[ORM\ManyToOne(inversedBy'chatFormations')]
  29.     private ?FormationElearning $formation null;
  30.     #[ORM\ManyToOne(targetEntityself::class, inversedBy'chatFormations')]
  31.     private ?self $parentMessage null;
  32.     #[ORM\OneToMany(mappedBy'parentMessage'targetEntityself::class)]
  33.     private Collection $chatFormations;
  34.     public function __construct()
  35.     {
  36.         $this->chatFormations = new ArrayCollection();
  37.     }
  38.     public function getId(): ?int { return $this->id; }
  39.     public function getMessage(): ?string { return $this->message; }
  40.     public function setMessage(string $message): self $this->message $message; return $this; }
  41.     public function getCreatedAt(): ?\DateTimeInterface { return $this->createdAt; }
  42.     public function setCreatedAt(\DateTimeInterface $createdAt): self $this->createdAt $createdAt; return $this; }
  43.     public function isRead(): ?bool { return $this->isRead; }
  44.     public function setIsRead(?bool $isRead): self $this->isRead $isRead; return $this; }
  45.     public function getSenderRole(): ?string { return $this->senderRole; }
  46.     public function setSenderRole(string $senderRole): self $this->senderRole $senderRole; return $this; }
  47.     public function getSender(): ?User
  48.     {
  49.         return $this->sender;
  50.     }
  51.     public function setSender(?User $sender): self
  52.     {
  53.         $this->sender $sender;
  54.         return $this;
  55.     }
  56.     public function getFormation(): ?FormationElearning
  57.     {
  58.         return $this->formation;
  59.     }
  60.     public function setFormation(?FormationElearning $formation): self
  61.     {
  62.         $this->formation $formation;
  63.         return $this;
  64.     }
  65.     public function getParentMessage(): ?self
  66.     {
  67.         return $this->parentMessage;
  68.     }
  69.     public function setParentMessage(?self $parentMessage): self
  70.     {
  71.         $this->parentMessage $parentMessage;
  72.         return $this;
  73.     }
  74.     /**
  75.      * @return Collection<int, self>
  76.      */
  77.     public function getChatFormations(): Collection
  78.     {
  79.         return $this->chatFormations;
  80.     }
  81.     public function addChatFormation(self $chatFormation): self
  82.     {
  83.         if (!$this->chatFormations->contains($chatFormation)) {
  84.             $this->chatFormations->add($chatFormation);
  85.             $chatFormation->setParentMessage($this);
  86.         }
  87.         return $this;
  88.     }
  89.     public function removeChatFormation(self $chatFormation): self
  90.     {
  91.         if ($this->chatFormations->removeElement($chatFormation)) {
  92.             // set the owning side to null (unless already changed)
  93.             if ($chatFormation->getParentMessage() === $this) {
  94.                 $chatFormation->setParentMessage(null);
  95.             }
  96.         }
  97.         return $this;
  98.     }
  99. }