src/Entity/QrCode.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use DateTime;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\HttpFoundation\File\File;
  6. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  7. #[ORM\Entity(repositoryClass"App\Repository\QrCodeRepository")]
  8. #[ORM\Table(name"qr_code")]
  9. class QrCode {
  10.     #[ORM\Column(type"boolean")]
  11.     private bool $isDeleted false;
  12.     #[ORM\Column(name"createdAt"type"datetime")]
  13.     private DateTime $createdAt;
  14.     #[ORM\ManyToOne(targetEntityUser::class, inversedBy"qrCodes")]
  15.     #[ORM\JoinColumn(nullablefalse)]
  16.     private User $user;
  17.     #[ORM\Column(type"integer")]
  18.     #[ORM\Id]
  19.     #[ORM\GeneratedValue(strategy"AUTO")]
  20.     private ?int $id;
  21.     /**
  22.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  23.      */
  24.     #[Vich\UploadableField(mapping"qrCode"fileNameProperty"qrCodeFileName"size"qrCodeFileSize")]
  25.     private ?File $qrCodeFile null;
  26.     #[ORM\Column(type"string"length255nullabletrue)]
  27.     private ?string $qrCodeFileName null;
  28.     #[ORM\Column(type"integer"nullabletrue)]
  29.     private ?int $qrCodeFileSize null;
  30.     #[ORM\Column(type"datetime"nullabletrue)]
  31.     private ?DateTime $qrCodeFileUpdatedAt null;
  32.     public function __construct() {
  33.         $this->createdAt = new DateTime();
  34.     }
  35.     public function __toString() {
  36.         return "#" $this->id " - " $this->qrCodeFileName;
  37.     }
  38.     /**
  39.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  40.      * of 'UploadedFile' is injected into this setter to trigger the  update. If this
  41.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  42.      * must be able to accept an instance of 'File' as the bundle will inject one here
  43.      * during Doctrine hydration.
  44.      *
  45.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $image
  46.      */
  47.     public function setQrCodeFile(File $image null) {
  48.         $this->qrCodeFile $image;
  49.         if (null !== $image) {
  50. // It is required that at least one field changes if you are using doctrine
  51. // otherwise the event listeners won't be called and the file is lost
  52.             $this->qrCodeFileUpdatedAt = new \DateTime();
  53.         }
  54.     }
  55.     public function getQrCodeFile() {
  56.         return $this->qrCodeFile;
  57.     }
  58.     /**
  59.      * Get id
  60.      *
  61.      * @return int
  62.      */
  63.     public function getId() {
  64.         return $this->id;
  65.     }
  66.     /**
  67.      * Set createdAt
  68.      *
  69.      * @param DateTime $createdAt
  70.      *
  71.      * @return QrCode
  72.      */
  73.     public function setCreatedAt($createdAt) {
  74.         $this->createdAt $createdAt;
  75.         return $this;
  76.     }
  77.     /**
  78.      * Get createdAt
  79.      *
  80.      * @return DateTime
  81.      */
  82.     public function getCreatedAt() {
  83.         return $this->createdAt;
  84.     }
  85.     /**
  86.      * Set qrCodeFileName
  87.      *
  88.      * @param string $qrCodeFileName
  89.      *
  90.      * @return QrCode
  91.      */
  92.     public function setQrCodeFileName($qrCodeFileName) {
  93.         $this->qrCodeFileName $qrCodeFileName;
  94.         return $this;
  95.     }
  96.     /**
  97.      * Get qrCodeFileName
  98.      *
  99.      * @return string
  100.      */
  101.     public function getQrCodeFileName() {
  102.         return $this->qrCodeFileName;
  103.     }
  104.     /**
  105.      * Set qrCodeFileSize
  106.      *
  107.      * @param integer $qrCodeFileSize
  108.      *
  109.      * @return QrCode
  110.      */
  111.     public function setQrCodeFileSize($qrCodeFileSize) {
  112.         $this->qrCodeFileSize $qrCodeFileSize;
  113.         return $this;
  114.     }
  115.     /**
  116.      * Get qrCodeFileSize
  117.      *
  118.      * @return integer
  119.      */
  120.     public function getQrCodeFileSize() {
  121.         return $this->qrCodeFileSize;
  122.     }
  123.     /**
  124.      * Set qrCodeFileUpdatedAt
  125.      *
  126.      * @param DateTime $qrCodeFileUpdatedAt
  127.      *
  128.      * @return QrCode
  129.      */
  130.     public function setQrCodeFileUpdatedAt($qrCodeFileUpdatedAt) {
  131.         $this->qrCodeFileUpdatedAt $qrCodeFileUpdatedAt;
  132.         return $this;
  133.     }
  134.     /**
  135.      * Get qrCodeFileUpdatedAt
  136.      *
  137.      * @return DateTime
  138.      */
  139.     public function getQrCodeFileUpdatedAt() {
  140.         return $this->qrCodeFileUpdatedAt;
  141.     }
  142.     /**
  143.      * Set user
  144.      *
  145.      * @param \App\Entity\User $user
  146.      *
  147.      * @return QrCode
  148.      */
  149.     public function setUser(\App\Entity\User $user) {
  150.         $this->user $user;
  151.         return $this;
  152.     }
  153.     /**
  154.      * Get user
  155.      *
  156.      * @return \App\Entity\User
  157.      */
  158.     public function getUser() {
  159.         return $this->user;
  160.     }
  161.     /**
  162.      * Set isDeleted
  163.      *
  164.      * @param boolean $isDeleted
  165.      *
  166.      * @return QrCode
  167.      */
  168.     public function setIsDeleted($isDeleted)
  169.     {
  170.         $this->isDeleted $isDeleted;
  171.         return $this;
  172.     }
  173.     /**
  174.      * Get isDeleted
  175.      *
  176.      * @return boolean
  177.      */
  178.     public function getIsDeleted()
  179.     {
  180.         return $this->isDeleted;
  181.     }
  182. }