src/Entity/ForumCommentReply.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ForumCommentReplyRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\Entity(repositoryClass=ForumCommentReplyRepository::class)
  8.  */
  9. class ForumCommentReply
  10. {
  11.     /**
  12.      * @ORM\Id
  13.      * @ORM\GeneratedValue
  14.      * @ORM\Column(type="integer")
  15.      */
  16.     private $id;
  17.     /**
  18.      * @ORM\Column(type="text")
  19.      */
  20.     private ?string $content;
  21.     /**
  22.      * @ORM\Column(type="datetime")
  23.      */
  24.     private ?\DateTimeInterface $createdAt;
  25.     /**
  26.      * @ORM\ManyToOne(targetEntity=ForumComment::class, inversedBy="commentReplies")
  27.      */
  28.     private ?ForumComment $comment;
  29.     /**
  30.      * @ORM\ManyToOne(targetEntity=ForumUser::class, inversedBy="forumCommentReplies")
  31.      */
  32.     private $forumUser;
  33.     //----------------------------------------------------------------
  34.     public function getTimeCreateString() {
  35.         $date $this->createdAt;
  36.         $today = new \DateTime();
  37.         $interval $today->diff($date);
  38.         if ($interval->days == 0) {
  39.             return 'Reply today';
  40.         } elseif ($interval->days == 1) {
  41.             return 'Reply 1 day ago';
  42.         } elseif ($interval->days >= && $interval->days <= 6) {
  43.             return 'Reply ' $interval->days ' days ago';
  44.         } else {
  45.             return 'Reply on ' $date->format('j M Y');
  46.         }
  47.     }
  48.     //----------------------------------------------------------------
  49.     public function __construct()
  50.     {
  51.         $this->createdAt = new \DateTime();
  52.     }
  53.     public function getId(): ?int
  54.     {
  55.         return $this->id;
  56.     }
  57.     public function getContent(): ?string
  58.     {
  59.         return $this->content;
  60.     }
  61.     public function setContent(string $content): self
  62.     {
  63.         $this->content $content;
  64.         return $this;
  65.     }
  66.     public function getCreatedAt(): ?\DateTimeInterface
  67.     {
  68.         return $this->createdAt;
  69.     }
  70.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  71.     {
  72.         $this->createdAt $createdAt;
  73.         return $this;
  74.     }
  75.     public function getComment(): ?ForumComment
  76.     {
  77.         return $this->comment;
  78.     }
  79.     public function setComment(?ForumComment $comment): self
  80.     {
  81.         $this->comment $comment;
  82.         return $this;
  83.     }
  84.     public function getForumUser(): ?ForumUser
  85.     {
  86.         return $this->forumUser;
  87.     }
  88.     public function setForumUser(?ForumUser $forumUser): self
  89.     {
  90.         $this->forumUser $forumUser;
  91.         return $this;
  92.     }
  93. }