<?phpnamespace App\Entity;use DateTime;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\HttpFoundation\File\File;use Vich\UploaderBundle\Mapping\Annotation as Vich;#[ORM\Entity(repositoryClass: "App\Repository\QrCodeRepository")]#[ORM\Table(name: "qr_code")]class QrCode { #[ORM\Column(type: "boolean")] private bool $isDeleted = false; #[ORM\Column(name: "createdAt", type: "datetime")] private DateTime $createdAt; #[ORM\ManyToOne(targetEntity: User::class, inversedBy: "qrCodes")] #[ORM\JoinColumn(nullable: false)] private User $user; #[ORM\Column(type: "integer")] #[ORM\Id] #[ORM\GeneratedValue(strategy: "AUTO")] private ?int $id; /** * NOTE: This is not a mapped field of entity metadata, just a simple property. */ #[Vich\UploadableField(mapping: "qrCode", fileNameProperty: "qrCodeFileName", size: "qrCodeFileSize")] private ?File $qrCodeFile = null; #[ORM\Column(type: "string", length: 255, nullable: true)] private ?string $qrCodeFileName = null; #[ORM\Column(type: "integer", nullable: true)] private ?int $qrCodeFileSize = null; #[ORM\Column(type: "datetime", nullable: true)] private ?DateTime $qrCodeFileUpdatedAt = null; public function __construct() { $this->createdAt = new DateTime(); } public function __toString() { return "#" . $this->id . " - " . $this->qrCodeFileName; } /** * If manually uploading a file (i.e. not using Symfony Form) ensure an instance * of 'UploadedFile' is injected into this setter to trigger the update. If this * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter * must be able to accept an instance of 'File' as the bundle will inject one here * during Doctrine hydration. * * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $image */ public function setQrCodeFile(File $image = null) { $this->qrCodeFile = $image; if (null !== $image) {// It is required that at least one field changes if you are using doctrine// otherwise the event listeners won't be called and the file is lost $this->qrCodeFileUpdatedAt = new \DateTime(); } } public function getQrCodeFile() { return $this->qrCodeFile; } /** * Get id * * @return int */ public function getId() { return $this->id; } /** * Set createdAt * * @param DateTime $createdAt * * @return QrCode */ public function setCreatedAt($createdAt) { $this->createdAt = $createdAt; return $this; } /** * Get createdAt * * @return DateTime */ public function getCreatedAt() { return $this->createdAt; } /** * Set qrCodeFileName * * @param string $qrCodeFileName * * @return QrCode */ public function setQrCodeFileName($qrCodeFileName) { $this->qrCodeFileName = $qrCodeFileName; return $this; } /** * Get qrCodeFileName * * @return string */ public function getQrCodeFileName() { return $this->qrCodeFileName; } /** * Set qrCodeFileSize * * @param integer $qrCodeFileSize * * @return QrCode */ public function setQrCodeFileSize($qrCodeFileSize) { $this->qrCodeFileSize = $qrCodeFileSize; return $this; } /** * Get qrCodeFileSize * * @return integer */ public function getQrCodeFileSize() { return $this->qrCodeFileSize; } /** * Set qrCodeFileUpdatedAt * * @param DateTime $qrCodeFileUpdatedAt * * @return QrCode */ public function setQrCodeFileUpdatedAt($qrCodeFileUpdatedAt) { $this->qrCodeFileUpdatedAt = $qrCodeFileUpdatedAt; return $this; } /** * Get qrCodeFileUpdatedAt * * @return DateTime */ public function getQrCodeFileUpdatedAt() { return $this->qrCodeFileUpdatedAt; } /** * Set user * * @param \App\Entity\User $user * * @return QrCode */ public function setUser(\App\Entity\User $user) { $this->user = $user; return $this; } /** * Get user * * @return \App\Entity\User */ public function getUser() { return $this->user; } /** * Set isDeleted * * @param boolean $isDeleted * * @return QrCode */ public function setIsDeleted($isDeleted) { $this->isDeleted = $isDeleted; return $this; } /** * Get isDeleted * * @return boolean */ public function getIsDeleted() { return $this->isDeleted; }}