src/Entity/ForumTopic.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ForumTopicRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. /**
  9.  * @ORM\Entity(repositoryClass=ForumTopicRepository::class)
  10.  */
  11. class ForumTopic
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      * @Groups("post")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="string", length=255, nullable=true)
  22.      * @Groups("post")
  23.      */
  24.     private $titre;
  25.     /**
  26.      * @ORM\ManyToOne(targetEntity=Forum::class, inversedBy="topic")
  27.      */
  28.     private $forum;
  29.     /**
  30.      * @ORM\OneToMany(targetEntity=ForumPost::class, mappedBy="forumTopic")
  31.      */
  32.     private $posts;
  33.     /**
  34.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="forumTopics")
  35.      */
  36.     private $user;
  37.     /**
  38.      * @ORM\Column(type="boolean", nullable=true)
  39.      */
  40.     private $isActive;
  41.     /**
  42.      * @ORM\OneToMany(targetEntity=Notification::class, mappedBy="topic")
  43.      */
  44.     private $notifications;
  45.     private $nbPost;
  46.     private $lastPost;
  47.     private $nbNotif;
  48.     public function __construct()
  49.     {
  50.         $this->posts = new ArrayCollection();
  51.         $this->nbPost 0;
  52.         $this->nbNotif 0;
  53.         $this->notifications = new ArrayCollection();
  54.     }
  55.     public function getId(): ?int
  56.     {
  57.         return $this->id;
  58.     }
  59.     public function getTitre(): ?string
  60.     {
  61.         return $this->titre;
  62.     }
  63.     public function setTitre(?string $titre): self
  64.     {
  65.         $this->titre $titre;
  66.         return $this;
  67.     }
  68.     public function getForum(): ?Forum
  69.     {
  70.         return $this->forum;
  71.     }
  72.     public function setForum(?Forum $forum): self
  73.     {
  74.         $this->forum $forum;
  75.         return $this;
  76.     }
  77.     /**
  78.      * @return Collection<int, ForumPost>
  79.      */
  80.     public function getPosts(): Collection
  81.     {
  82.         return $this->posts;
  83.     }
  84.     public function addPost(ForumPost $post): self
  85.     {
  86.         if (!$this->posts->contains($post)) {
  87.             $this->posts[] = $post;
  88.             $post->setForumTopic($this);
  89.         }
  90.         return $this;
  91.     }
  92.     public function removePost(ForumPost $post): self
  93.     {
  94.         if ($this->posts->removeElement($post)) {
  95.             // set the owning side to null (unless already changed)
  96.             if ($post->getForumTopic() === $this) {
  97.                 $post->setForumTopic(null);
  98.             }
  99.         }
  100.         return $this;
  101.     }
  102.     public function getUser(): ?User
  103.     {
  104.         return $this->user;
  105.     }
  106.     public function setUser(?User $user): self
  107.     {
  108.         $this->user $user;
  109.         return $this;
  110.     }
  111.     public function getIsActive(): ?bool
  112.     {
  113.         return $this->isActive;
  114.     }
  115.     public function setIsActive(?bool $isActive): self
  116.     {
  117.         $this->isActive $isActive;
  118.         return $this;
  119.     }
  120.     /**
  121.      * Get the value of nbPost
  122.      */ 
  123.     public function getNbPost()
  124.     {
  125.         return $this->nbPost;
  126.     }
  127.     /**
  128.      * Set the value of nbPost
  129.      *
  130.      * @return  self
  131.      */ 
  132.     public function setNbPost($nbPost)
  133.     {
  134.         $this->nbPost $nbPost;
  135.         return $this;
  136.     }
  137.     /**
  138.      * Get the value of lastPost
  139.      */ 
  140.     public function getLastPost()
  141.     {
  142.         return $this->lastPost;
  143.     }
  144.     /**
  145.      * Set the value of lastPost
  146.      *
  147.      * @return  self
  148.      */ 
  149.     public function setLastPost($lastPost)
  150.     {
  151.         $this->lastPost $lastPost;
  152.         return $this;
  153.     }
  154.     /**
  155.      * @return Collection<int, Notification>
  156.      */
  157.     public function getNotifications(): Collection
  158.     {
  159.         return $this->notifications;
  160.     }
  161.     public function addNotification(Notification $notification): self
  162.     {
  163.         if (!$this->notifications->contains($notification)) {
  164.             $this->notifications[] = $notification;
  165.             $notification->setTopic($this);
  166.         }
  167.         return $this;
  168.     }
  169.     public function removeNotification(Notification $notification): self
  170.     {
  171.         if ($this->notifications->removeElement($notification)) {
  172.             // set the owning side to null (unless already changed)
  173.             if ($notification->getTopic() === $this) {
  174.                 $notification->setTopic(null);
  175.             }
  176.         }
  177.         return $this;
  178.     }
  179.     /**
  180.      * Get the value of nbNotif
  181.      */ 
  182.     public function getNbNotif()
  183.     {
  184.         return $this->nbNotif;
  185.     }
  186.     /**
  187.      * Set the value of nbNotif
  188.      *
  189.      * @return  self
  190.      */ 
  191.     public function setNbNotif($nbNotif)
  192.     {
  193.         $this->nbNotif $nbNotif;
  194.         return $this;
  195.     }
  196. }