src/Entity/Report.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use App\Traits\CreatedUpdatedTrait;
  5. use JMS\Serializer\Annotation\Expose;
  6. use JMS\Serializer\Annotation\ExclusionPolicy;
  7. use Symfony\Component\HttpFoundation\File\File;
  8. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  9. /**
  10.  * Report
  11.  *
  12.  * @ORM\Table(name="v_report")
  13.  * @ORM\Entity()
  14.  *
  15.  * @ExclusionPolicy("all")
  16.  * @Vich\Uploadable
  17.  */
  18. class Report
  19. {
  20.     /**
  21.      * @ORM\Id()
  22.      * @ORM\GeneratedValue()
  23.      * @ORM\Column(type="integer")
  24.      */
  25.     private $id;
  26.     /**
  27.      * @ORM\ManyToOne(targetEntity="App\Entity\User")
  28.      */
  29.     private $user;
  30.     /**
  31.      * @var string
  32.      *
  33.      * @ORM\Column(name="message", type="text", nullable=true)
  34.      * @Expose
  35.      */
  36.     private $message;
  37.     /**
  38.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  39.      *
  40.      * @Vich\UploadableField(mapping="report_files", fileNameProperty="fileName")
  41.      *
  42.      * @var File
  43.      */
  44.     private $reportFile;
  45.     /**
  46.      * @ORM\Column(name="file_name", type="string", length=255, nullable=true)
  47.      *
  48.      * @var string
  49.      */
  50.     private $fileName;
  51.     use CreatedUpdatedTrait;
  52.     public function __toString()
  53.     {
  54.         return (string) $this->message;
  55.     }
  56.     /**
  57.      * Get id
  58.      *
  59.      * @return integer 
  60.      */
  61.     public function getId()
  62.     {
  63.         return $this->id;
  64.     }
  65.     /**
  66.      * @return mixed
  67.      */
  68.     public function getUser()
  69.     {
  70.         return $this->user;
  71.     }
  72.     /**
  73.      * @param mixed $user
  74.      */
  75.     public function setUser($user)
  76.     {
  77.         $this->user $user;
  78.     }
  79.     /**
  80.      * Set message
  81.      *
  82.      * @param string $message
  83.      * @return Report
  84.      */
  85.     public function setMessage($message)
  86.     {
  87.         $this->message $message;
  88.         return $this;
  89.     }
  90.     /**
  91.      * Get message
  92.      *
  93.      * @return string 
  94.      */
  95.     public function getMessage()
  96.     {
  97.         return $this->message;
  98.     }
  99.     /**
  100.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  101.      * of 'UploadedFile' is injected into this setter to trigger the  update. If this
  102.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  103.      * must be able to accept an instance of 'File' as the bundle will inject one here
  104.      * during Doctrine hydration.
  105.      *
  106.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $file
  107.      */
  108.     public function setReportFile(File $file null)
  109.     {
  110.         $this->reportFile $file;
  111.         if ($file) {
  112.             // It is required that at least one field changes if you are using doctrine
  113.             // otherwise the event listeners won't be called and the file is lost
  114.             $this->updated = new \DateTime('now');
  115.         }
  116.     }
  117.     /**
  118.      * @return File
  119.      */
  120.     public function getReportFile()
  121.     {
  122.         return $this->reportFile;
  123.     }
  124.     /**
  125.      * @param string $fileName
  126.      */
  127.     public function setFileName($fileName)
  128.     {
  129.         $this->fileName $fileName;
  130.     }
  131.     /**
  132.      * @return string
  133.      */
  134.     public function getFileName()
  135.     {
  136.         return $this->fileName;
  137.     }
  138. }