src/Entity/SubjectChat.php line 12

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SubjectChatRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassSubjectChatRepository::class)]
  8. #[ORM\Table(name'subject_chat')] // Keep the table name for DB compatibility
  9. class SubjectChat
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\ManyToOne(inversedBy'subjectChats')]
  16.     #[ORM\JoinColumn(nullablefalse)]
  17.     private ?Categorie $matiere null;
  18.     #[ORM\Column]
  19.     private ?int $cycle null;
  20.     #[ORM\Column(length255)]
  21.     private ?string $name null;
  22.     #[ORM\OneToMany(mappedBy'subjectChat'targetEntityMessageChat::class, orphanRemovaltrue)]
  23.     private Collection $messageChats;
  24.     #[ORM\Column(name'created_at'type'datetime_immutable')]
  25.     private ?\DateTimeImmutable $createdAt null;
  26.     #[ORM\OneToMany(mappedBy'subjectChat'targetEntityWebSocketConnection::class, orphanRemovaltrue)]
  27.     private Collection $webSocketConnections;
  28.     #[ORM\ManyToOne(inversedBy'subjectChats')]
  29.     #[ORM\JoinColumn(nullablefalse)]
  30.     private ?Eleve $eleve null;
  31.     #[ORM\ManyToOne(inversedBy'subjectChats')]
  32.     #[ORM\JoinColumn(nullabletrue)]
  33.     private ?Enseignant $teacherPersona null;
  34.     public function __construct()
  35.     {
  36.         $this->messageChats = new ArrayCollection();
  37.         $this->createdAt = new \DateTimeImmutable;
  38.         $this->webSocketConnections = new ArrayCollection();
  39.     }
  40.     public function getId(): ?int
  41.     {
  42.         return $this->id;
  43.     }
  44.     public function getMatiere(): ?Categorie
  45.     {
  46.         return $this->matiere;
  47.     }
  48.     public function setMatiere(?Categorie $matiere): static
  49.     {
  50.         $this->matiere $matiere;
  51.         return $this;
  52.     }
  53.     public function getCycle(): ?int
  54.     {
  55.         return $this->cycle;
  56.     }
  57.     public function setCycle(int $cycle): static
  58.     {
  59.         $this->cycle $cycle;
  60.         return $this;
  61.     }
  62.     public function getName(): ?string
  63.     {
  64.         return $this->name;
  65.     }
  66.     public function setName(string $name): static
  67.     {
  68.         $this->name $name;
  69.         return $this;
  70.     }
  71.     /**
  72.      * @return Collection<int, MessageChat>
  73.      */
  74.     public function getMessageChats(): Collection
  75.     {
  76.         return $this->messageChats;
  77.     }
  78.     public function addMessageChat(MessageChat $messageChat): static
  79.     {
  80.         if (!$this->messageChats->contains($messageChat)) {
  81.             $this->messageChats->add($messageChat);
  82.             $messageChat->setSubjectChat($this);
  83.         }
  84.         return $this;
  85.     }
  86.     public function removeMessageChat(MessageChat $messageChat): static
  87.     {
  88.         if ($this->messageChats->removeElement($messageChat)) {
  89.             if ($messageChat->getSubjectChat() === $this) {
  90.                 $messageChat->setSubjectChat(null);
  91.             }
  92.         }
  93.         return $this;
  94.     }
  95.     public function getCreatedAt(): ?\DateTimeImmutable
  96.     {
  97.         return $this->createdAt;
  98.     }
  99.     public function setCreatedAt(\DateTimeImmutable $createdAt): static
  100.     {
  101.         $this->createdAt $createdAt;
  102.         return $this;
  103.     }
  104.     /**
  105.      * @return Collection<int, WebSocketConnection>
  106.      */
  107.     public function getWebSocketConnections(): Collection
  108.     {
  109.         return $this->webSocketConnections;
  110.     }
  111.     public function addWebSocketConnection(WebSocketConnection $webSocketConnection): static
  112.     {
  113.         if (!$this->webSocketConnections->contains($webSocketConnection)) {
  114.             $this->webSocketConnections->add($webSocketConnection);
  115.             $webSocketConnection->setSubjectChat($this);
  116.         }
  117.         return $this;
  118.     }
  119.     public function removeWebSocketConnection(WebSocketConnection $webSocketConnection): static
  120.     {
  121.         if ($this->webSocketConnections->removeElement($webSocketConnection)) {
  122.             if ($webSocketConnection->getSubjectChat() === $this) {
  123.                 $webSocketConnection->setSubjectChat(null);
  124.             }
  125.         }
  126.         return $this;
  127.     }
  128.     public function getEleve(): ?Eleve
  129.     {
  130.         return $this->eleve;
  131.     }
  132.     public function setEleve(?Eleve $eleve): static
  133.     {
  134.         $this->eleve $eleve;
  135.         return $this;
  136.     }
  137.     public function getTeacherPersona(): ?Enseignant
  138.     {
  139.         return $this->teacherPersona;
  140.     }
  141.     public function setTeacherPersona(?Enseignant $teacherPersona): static
  142.     {
  143.         $this->teacherPersona $teacherPersona;
  144.         return $this;
  145.     }
  146. }