src/Entity/Forum/PostReply.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Forum;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use App\Traits\CreatedUpdatedTrait;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use JMS\Serializer\Annotation\Exclude;
  7. use JMS\Serializer\Annotation as JMS;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  10. /**
  11.  * @ORM\Table(name="v_forum_post_reply")
  12.  * @ORM\Entity(repositoryClass="App\Repository\Forum\PostReplyRepository")
  13.  * @Vich\Uploadable
  14.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
  15.  */
  16. class PostReply
  17. {
  18.     /**
  19.      * @ORM\Id()
  20.      * @ORM\GeneratedValue()
  21.      * @ORM\Column(type="integer")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @ORM\ManyToOne(targetEntity="App\Entity\Forum\Post")
  26.      * @Exclude
  27.      */
  28.     private $post;
  29.     /**
  30.      * @ORM\ManyToOne(targetEntity="App\Entity\User")
  31.      * @Exclude
  32.      */
  33.     private $user;
  34.     /**
  35.      * @ORM\ManyToOne(targetEntity="App\Entity\Admin")
  36.      * @Exclude
  37.      */
  38.     private $admin;
  39.     /**
  40.      * @ORM\ManyToOne(targetEntity="App\Entity\Forum\PostReply")
  41.      * @Exclude
  42.      */
  43.     private $reply;
  44.     /**
  45.      * @ORM\Column(type="text")
  46.      */
  47.     private $message;
  48.     /**
  49.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  50.      *
  51.      * @Vich\UploadableField(mapping="forum_files", fileNameProperty="image")
  52.      *
  53.      * @var File
  54.      * @Exclude
  55.      */
  56.     private $imageFile;
  57.     /**
  58.      * @ORM\Column(name="image", type="string", length=255, nullable=true)
  59.      *
  60.      * @var string
  61.      */
  62.     private $image;
  63.     /**
  64.      * @ORM\Column(type="boolean")
  65.      */
  66.     private $banned false;
  67.     /**
  68.      * @ORM\Column(name="deleted_at", type="datetime", nullable=true)
  69.      */
  70.     private $deletedAt;
  71.     use CreatedUpdatedTrait;
  72.     public function __toString()
  73.     {
  74.         return $this->message;
  75.     }
  76.     public function getId(): ?int
  77.     {
  78.         return $this->id;
  79.     }
  80.     /**
  81.      * @return mixed
  82.      */
  83.     public function getPost()
  84.     {
  85.         return $this->post;
  86.     }
  87.     /**
  88.      * @param mixed $post
  89.      */
  90.     public function setPost($post): void
  91.     {
  92.         $this->post $post;
  93.     }
  94.     /**
  95.      * @return mixed
  96.      */
  97.     public function getUser()
  98.     {
  99.         return $this->user;
  100.     }
  101.     /**
  102.      * @param mixed $user
  103.      */
  104.     public function setUser($user): void
  105.     {
  106.         $this->user $user;
  107.     }
  108.     /**
  109.      * @return mixed
  110.      */
  111.     public function getAdmin()
  112.     {
  113.         return $this->admin;
  114.     }
  115.     /**
  116.      * @param mixed $admin
  117.      */
  118.     public function setAdmin($admin): void
  119.     {
  120.         $this->admin $admin;
  121.     }
  122.     /**
  123.      * @return mixed
  124.      */
  125.     public function getReply()
  126.     {
  127.         return $this->reply;
  128.     }
  129.     /**
  130.      * @param mixed $reply
  131.      */
  132.     public function setReply($reply): void
  133.     {
  134.         $this->reply $reply;
  135.     }
  136.     /**
  137.      * @return mixed
  138.      */
  139.     public function getMessage()
  140.     {
  141.         return $this->message;
  142.     }
  143.     /**
  144.      * @param mixed $message
  145.      */
  146.     public function setMessage($message): void
  147.     {
  148.         $this->message $message;
  149.     }
  150.     /**
  151.      * @JMS\VirtualProperty
  152.      * @JMS\SerializedName("user_id")
  153.      *
  154.      * @return string
  155.      */
  156.     public function getUserId()
  157.     {
  158.         return $this->getUser() ? $this->getUser()->getId() : 0;
  159.     }
  160.     /**
  161.      * @JMS\VirtualProperty
  162.      * @JMS\SerializedName("user_name")
  163.      *
  164.      * @return string
  165.      */
  166.     public function getUserName()
  167.     {
  168.         if($this->getUser()){
  169.             return $this->getUser()->getName();
  170.         }elseif($this->getAdmin()){
  171.             return 'IdealOfMed';
  172.         }else{
  173.             return '';
  174.         }
  175.     }
  176.     /**
  177.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  178.      * of 'UploadedFile' is injected into this setter to trigger the  update. If this
  179.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  180.      * must be able to accept an instance of 'File' as the bundle will inject one here
  181.      * during Doctrine hydration.
  182.      *
  183.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $file
  184.      */
  185.     public function setImageFile(File $file null)
  186.     {
  187.         $this->imageFile $file;
  188.         if ($file) {
  189.             // It is required that at least one field changes if you are using doctrine
  190.             // otherwise the event listeners won't be called and the file is lost
  191.             $this->updated = new \DateTime('now');
  192.         }
  193.     }
  194.     /**
  195.      * @return File
  196.      */
  197.     public function getImageFile()
  198.     {
  199.         return $this->imageFile;
  200.     }
  201.     /**
  202.      * @param string $image
  203.      */
  204.     public function setImage($image)
  205.     {
  206.         $this->image $image;
  207.     }
  208.     /**
  209.      * @return string
  210.      */
  211.     public function getImage()
  212.     {
  213.         return $this->image;
  214.     }
  215.     /**
  216.      * @return bool
  217.      */
  218.     public function isBanned(): ?bool
  219.     {
  220.         return $this->banned;
  221.     }
  222.     /**
  223.      * @param bool $banned
  224.      */
  225.     public function setBanned(?bool $banned): void
  226.     {
  227.         $this->banned $banned;
  228.     }
  229.     /**
  230.      * @return mixed
  231.      */
  232.     public function getDeletedAt()
  233.     {
  234.         return $this->deletedAt;
  235.     }
  236.     /**
  237.      * @param mixed $deletedAt
  238.      */
  239.     public function setDeletedAt($deletedAt): void
  240.     {
  241.         $this->deletedAt $deletedAt;
  242.     }
  243. }