src/Entity/Message.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\MessageRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Serializer\Annotation\Groups;
  6. /**
  7.  * @ORM\Entity(repositoryClass=MessageRepository::class)
  8.  */
  9. class Message
  10. {
  11.     /**
  12.      * @ORM\Id
  13.      * @ORM\GeneratedValue
  14.      * @ORM\Column(type="integer")
  15.      * @Groups("message")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\ManyToOne(targetEntity=Conversation::class, inversedBy="messages")
  20.      * @Groups("message")
  21.      */
  22.     private $conversation;
  23.     /**
  24.      * @ORM\Column(type="text", nullable=true)
  25.      * @Groups("message")
  26.      */
  27.     private $content;
  28.     /**
  29.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="messages")
  30.      * @Groups("message")
  31.      */
  32.     private $user;
  33.     /**
  34.      * @ORM\Column(type="datetime", nullable=true)
  35.      * @Groups("message")
  36.      */
  37.     private $createdAt;
  38.     /**
  39.      * @Groups("message")
  40.      */
  41.     private $createdAtFr;
  42.     public function __construct()
  43.     { 
  44.         $this->createdAt = new \DateTime();
  45.     }
  46.     public function getId(): ?int
  47.     {
  48.         return $this->id;
  49.     }
  50.     public function getConversation(): ?Conversation
  51.     {
  52.         return $this->conversation;
  53.     }
  54.     public function setConversation(?Conversation $conversation): self
  55.     {
  56.         $this->conversation $conversation;
  57.         return $this;
  58.     }
  59.     public function getContent(): ?string
  60.     {
  61.         return $this->content;
  62.     }
  63.     public function setContent(?string $content): self
  64.     {
  65.         $this->content $content;
  66.         return $this;
  67.     }
  68.     public function getUser(): ?User
  69.     {
  70.         return $this->user;
  71.     }
  72.     public function setUser(?User $user): self
  73.     {
  74.         $this->user $user;
  75.         return $this;
  76.     }
  77.     public function getCreatedAt(): ?\DateTimeInterface
  78.     {
  79.         return $this->createdAt;
  80.     }
  81.     public function setCreatedAt(?\DateTimeInterface $createdAt): self
  82.     {
  83.         $this->createdAt $createdAt;
  84.         return $this;
  85.     }
  86.     /**
  87.      * Get the value of createdAtFr
  88.      */ 
  89.     public function getCreatedAtFr()
  90.     {
  91.         $this->createdAtFr $this->createdAt->format('d/m/Y H:i:s');
  92.         
  93.         return $this->createdAtFr;
  94.     }
  95. }