<?phpnamespace App\Entity;use App\Repository\ForumTopicRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Serializer\Annotation\Groups;/** * @ORM\Entity(repositoryClass=ForumTopicRepository::class) */class ForumTopic{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") * @Groups("post") */ private $id; /** * @ORM\Column(type="string", length=255, nullable=true) * @Groups("post") */ private $titre; /** * @ORM\ManyToOne(targetEntity=Forum::class, inversedBy="topic") */ private $forum; /** * @ORM\OneToMany(targetEntity=ForumPost::class, mappedBy="forumTopic") */ private $posts; /** * @ORM\ManyToOne(targetEntity=User::class, inversedBy="forumTopics") */ private $user; /** * @ORM\Column(type="boolean", nullable=true) */ private $isActive; /** * @ORM\OneToMany(targetEntity=Notification::class, mappedBy="topic") */ private $notifications; private $nbPost; private $lastPost; private $nbNotif; public function __construct() { $this->posts = new ArrayCollection(); $this->nbPost = 0; $this->nbNotif = 0; $this->notifications = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getTitre(): ?string { return $this->titre; } public function setTitre(?string $titre): self { $this->titre = $titre; return $this; } public function getForum(): ?Forum { return $this->forum; } public function setForum(?Forum $forum): self { $this->forum = $forum; return $this; } /** * @return Collection<int, ForumPost> */ public function getPosts(): Collection { return $this->posts; } public function addPost(ForumPost $post): self { if (!$this->posts->contains($post)) { $this->posts[] = $post; $post->setForumTopic($this); } return $this; } public function removePost(ForumPost $post): self { if ($this->posts->removeElement($post)) { // set the owning side to null (unless already changed) if ($post->getForumTopic() === $this) { $post->setForumTopic(null); } } return $this; } public function getUser(): ?User { return $this->user; } public function setUser(?User $user): self { $this->user = $user; return $this; } public function getIsActive(): ?bool { return $this->isActive; } public function setIsActive(?bool $isActive): self { $this->isActive = $isActive; return $this; } /** * Get the value of nbPost */ public function getNbPost() { return $this->nbPost; } /** * Set the value of nbPost * * @return self */ public function setNbPost($nbPost) { $this->nbPost = $nbPost; return $this; } /** * Get the value of lastPost */ public function getLastPost() { return $this->lastPost; } /** * Set the value of lastPost * * @return self */ public function setLastPost($lastPost) { $this->lastPost = $lastPost; return $this; } /** * @return Collection<int, Notification> */ public function getNotifications(): Collection { return $this->notifications; } public function addNotification(Notification $notification): self { if (!$this->notifications->contains($notification)) { $this->notifications[] = $notification; $notification->setTopic($this); } return $this; } public function removeNotification(Notification $notification): self { if ($this->notifications->removeElement($notification)) { // set the owning side to null (unless already changed) if ($notification->getTopic() === $this) { $notification->setTopic(null); } } return $this; } /** * Get the value of nbNotif */ public function getNbNotif() { return $this->nbNotif; } /** * Set the value of nbNotif * * @return self */ public function setNbNotif($nbNotif) { $this->nbNotif = $nbNotif; return $this; }}