src/Entity/Conversation.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ConversationRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassConversationRepository::class)]
  8. class Conversation
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column(type'integer')]
  13.     private $id;
  14.     #[ORM\OneToOne(targetEntityMessage::class, cascade: ['persist''remove'])]
  15.     private $lastMessage;
  16.     #[ORM\OneToMany(targetEntityMessage::class, mappedBy'conversation')]
  17.     private $messages;
  18.     #[ORM\OneToMany(targetEntityParticipant::class, mappedBy'conversation')]
  19.     private $participants;
  20.     #[ORM\Column(type'string'length255)]
  21.     private $token;
  22.     #[ORM\ManyToOne(targetEntityUser::class, inversedBy'traineeConversations')]
  23.     private $trainee;
  24.     #[ORM\ManyToOne(targetEntityUser::class, inversedBy'proConversations')]
  25.     private $pro;
  26.     #[ORM\Column(type'datetime'nullabletrue)]
  27.     private $lastActivity;
  28.     #[ORM\Column(type'string'length255nullabletrue)]
  29.     private $proLocale;
  30.     #[ORM\Column(type'string'length255nullabletrue)]
  31.     private $traineeLocale;
  32.     #[ORM\Column(type'string'length255nullabletrue)]
  33.     private $firstActivity;
  34.     public function __construct()
  35.     {
  36.         $this->messages = new ArrayCollection();
  37.         $this->participants = new ArrayCollection();
  38.     }
  39.     public function getId(): ?int
  40.     {
  41.         return $this->id;
  42.     }
  43.     public function getLastMessage(): ?Message
  44.     {
  45.         return $this->lastMessage;
  46.     }
  47.     public function setLastMessage(?Message $lastMessage): self
  48.     {
  49.         $this->lastMessage $lastMessage;
  50.         return $this;
  51.     }
  52.     /**
  53.      * @return Collection|Message[]
  54.      */
  55.     public function getMessages(): Collection
  56.     {
  57.         return $this->messages;
  58.     }
  59.     public function addMessage(Message $message): self
  60.     {
  61.         if (!$this->messages->contains($message)) {
  62.             $this->messages[] = $message;
  63.             $message->setConversation($this);
  64.         }
  65.         return $this;
  66.     }
  67.     public function removeMessage(Message $message): self
  68.     {
  69.         if ($this->messages->removeElement($message)) {
  70.             // set the owning side to null (unless already changed)
  71.             if ($message->getConversation() === $this) {
  72.                 $message->setConversation(null);
  73.             }
  74.         }
  75.         return $this;
  76.     }
  77.     /**
  78.      * @return Collection|Participant[]
  79.      */
  80.     public function getParticipants(): Collection
  81.     {
  82.         return $this->participants;
  83.     }
  84.     public function addParticipant(Participant $participant): self
  85.     {
  86.         if (!$this->participants->contains($participant)) {
  87.             $this->participants[] = $participant;
  88.             $participant->setConversation($this);
  89.         }
  90.         return $this;
  91.     }
  92.     public function removeParticipant(Participant $participant): self
  93.     {
  94.         if ($this->participants->removeElement($participant)) {
  95.             // set the owning side to null (unless already changed)
  96.             if ($participant->getConversation() === $this) {
  97.                 $participant->setConversation(null);
  98.             }
  99.         }
  100.         return $this;
  101.     }
  102.     public function getToken(): ?string
  103.     {
  104.         return $this->token;
  105.     }
  106.     public function setToken(string $token): self
  107.     {
  108.         $this->token $token;
  109.         return $this;
  110.     }
  111.     public function getTrainee(): ?User
  112.     {
  113.         return $this->trainee;
  114.     }
  115.     public function setTrainee(?User $trainee): self
  116.     {
  117.         $this->trainee $trainee;
  118.         return $this;
  119.     }
  120.     public function getPro(): ?User
  121.     {
  122.         return $this->pro;
  123.     }
  124.     public function setPro(?User $pro): self
  125.     {
  126.         $this->pro $pro;
  127.         return $this;
  128.     }
  129.     public function getLastActivity(): ?\DateTimeInterface
  130.     {
  131.         return $this->lastActivity;
  132.     }
  133.     public function setLastActivity(\DateTimeInterface $lastActivity): self
  134.     {
  135.         $this->lastActivity $lastActivity;
  136.         return $this;
  137.     }
  138.     public function getProLocale(): ?string
  139.     {
  140.         return $this->proLocale;
  141.     }
  142.     public function setProLocale(?string $proLocale): self
  143.     {
  144.         $this->proLocale $proLocale;
  145.         return $this;
  146.     }
  147.     public function getTraineeLocale(): ?string
  148.     {
  149.         return $this->traineeLocale;
  150.     }
  151.     public function setTraineeLocale(?string $traineeLocale): self
  152.     {
  153.         $this->traineeLocale $traineeLocale;
  154.         return $this;
  155.     }
  156.     public function getFirstActivity(): ?string
  157.     {
  158.         return $this->firstActivity;
  159.     }
  160.     public function setFirstActivity(?string $firstActivity): self
  161.     {
  162.         $this->firstActivity $firstActivity;
  163.         return $this;
  164.     }
  165. }