src/Entity/Chats.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Media\Media;
  4. use App\Entity\Program\Program;
  5. use App\Repository\ChatsRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. /**
  10.  * @ORM\Entity(repositoryClass=ChatsRepository::class)
  11.  * @ORM\HasLifecycleCallbacks()
  12.  */
  13. class Chats extends BaseEntity
  14. {
  15.     /**
  16.      * @ORM\ManyToOne(targetEntity="App\Entity\Media\Media", inversedBy="chats")
  17.      * @ORM\JoinColumn(onDelete="CASCADE")
  18.      */
  19.     private $media;
  20.     /**
  21.      * @ORM\ManyToOne(targetEntity="App\Entity\Program\Program", inversedBy="chats")
  22.      * @ORM\JoinColumn(onDelete="CASCADE")
  23.      */
  24.     private $program;
  25.     /**
  26.      * @ORM\ManyToOne(targetEntity="App\Entity\User")
  27.      * @ORM\JoinColumn(onDelete="CASCADE")
  28.      */
  29.     private $user;
  30.     /**
  31.      * @ORM\OneToMany(targetEntity="App\Entity\ChatsContent",mappedBy="chat",cascade={"persist"}, orphanRemoval=true)
  32.      */
  33.     private $contents;
  34.     /**
  35.      * @ORM\Column(type="integer", nullable=false)
  36.      */
  37.     private $numberMessageNonLuForUser;
  38.     /**
  39.      * @ORM\Column(type="integer", nullable=false)
  40.      * retourne de message envoyé a une media ou un program non lu
  41.      */
  42.     private $numberMessageNonLuForChannel;
  43.     /**
  44.      * @ORM\Column(type="datetime", options={"default" = "CURRENT_TIMESTAMP"})
  45.      */
  46.     protected $lastMessageDate;
  47.     public function __construct()
  48.     {
  49.         $this->contents = new ArrayCollection();
  50.         $this->numberMessageNonLuForUser 0;
  51.         $this->numberMessageNonLuForChannel 0;
  52.     }
  53.     public function getId(): ?int
  54.     {
  55.         return $this->id;
  56.     }
  57.     public function getMedia(): ?Media
  58.     {
  59.         return $this->media;
  60.     }
  61.     public function setMedia(?Media $media): self
  62.     {
  63.         $this->media $media;
  64.         return $this;
  65.     }
  66.     public function getProgram(): ?Program
  67.     {
  68.         return $this->program;
  69.     }
  70.     public function setProgram(?Program $program): self
  71.     {
  72.         $this->program $program;
  73.         return $this;
  74.     }
  75.     public function getUser(): ?User
  76.     {
  77.         return $this->user;
  78.     }
  79.     public function setUser(?User $user): self
  80.     {
  81.         $this->user $user;
  82.         return $this;
  83.     }
  84.     /**
  85.      * @return Collection|ChatsContent[]
  86.      */
  87.     public function getContents(): Collection
  88.     {
  89.         return $this->contents;
  90.     }
  91.     public function addContent(ChatsContent $content): self
  92.     {
  93.         if (!$this->contents->contains($content)) {
  94.             $this->contents[] = $content;
  95.             $content->setChat($this);
  96.         }
  97.         return $this;
  98.     }
  99.     public function removeContent(ChatsContent $content): self
  100.     {
  101.         if ($this->contents->removeElement($content)) {
  102.             // set the owning side to null (unless already changed)
  103.             if ($content->getChat() === $this) {
  104.                 $content->setChat(null);
  105.             }
  106.         }
  107.         return $this;
  108.     }
  109.     public function getNumberMessageNonLuForUser(): ?int
  110.     {
  111.         return $this->numberMessageNonLuForUser;
  112.     }
  113.     public function setNumberMessageNonLuForUser(int $numberMessageNonLuForUser): self
  114.     {
  115.         $this->numberMessageNonLuForUser $numberMessageNonLuForUser;
  116.         return $this;
  117.     }
  118.     public function getLastMessageDate(): ?\DateTimeInterface
  119.     {
  120.         return $this->lastMessageDate;
  121.     }
  122.     public function setLastMessageDate(\DateTimeInterface $lastMessageDate): self
  123.     {
  124.         $this->lastMessageDate $lastMessageDate;
  125.         return $this;
  126.     }
  127.     public function getNumberMessageNonLuForChannel(): ?int
  128.     {
  129.         return $this->numberMessageNonLuForChannel;
  130.     }
  131.     public function setNumberMessageNonLuForChannel(int $numberMessageNonLuForChannel): self
  132.     {
  133.         $this->numberMessageNonLuForChannel $numberMessageNonLuForChannel;
  134.         return $this;
  135.     }
  136. }