<?php
namespace App\Entity;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Serializable;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @Vich\Uploadable
*/
#[ORM\Entity(repositoryClass: "App\Repository\IdentityCardRepository")]
#[ORM\Table(name: "identity_card_photo")]
class IdentityCardPhoto implements Serializable {
#[ORM\Column(type: "boolean")]
private bool $isDeleted = false;
#[ORM\Column(name: "createdAt", type: "datetime")]
private DateTime $createdAt;
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: "identityCardPhotos")]
#[ORM\JoinColumn(nullable: false)]
private User $user;
#[ORM\Column(name: "id", type: "integer")]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: "AUTO")]
private ?int $id = null;
/**
* @Vich\UploadableField(mapping="identityCardPhoto", fileNameProperty="identityCardPhotoFileName", size="identityCardPhotoFileSize")
*/
#[Assert\File(maxSize: "4M", groups: ['identityCard'])]
private ?File $identityCardPhotoFile = null;
#[ORM\Column(type: "string", length: 255, nullable: true)]
private ?string $identityCardPhotoFileName = null;
#[ORM\Column(type: "integer", nullable: true)]
private ?int $identityCardPhotoFileSize = null;
#[ORM\Column(type: "datetime", nullable: true)]
private ?DateTime $identityCardPhotoFileUpdatedAt;
public function __construct() {
$this->createdAt = new DateTime();
}
public function __toString() {
return "#" . $this->id . " - " . $this->identityCardPhotoFileName;
}
/**
* 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 setIdentityCardPhotoFile(File $image = null) {
$this->identityCardPhotoFile = $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->identityCardPhotoFileUpdatedAt = new DateTime();
}
}
public function getIdentityCardPhotoFile() {
return $this->identityCardPhotoFile;
}
/**
* Get id
*
* @return int
*/
public function getId() {
return $this->id;
}
/**
* Set createdAt
*
* @param DateTime $createdAt
*
* @return IdentityCardPhoto
*/
public function setCreatedAt($createdAt) {
$this->createdAt = $createdAt;
return $this;
}
/**
* Get createdAt
*
* @return DateTime
*/
public function getCreatedAt() {
return $this->createdAt;
}
/**
* Set identityCardPhotoFileName
*
* @param string $identityCardPhotoFileName
*
* @return IdentityCardPhoto
*/
public function setIdentityCardPhotoFileName($identityCardPhotoFileName) {
$this->identityCardPhotoFileName = $identityCardPhotoFileName;
return $this;
}
/**
* Get identityCardPhotoFileName
*
* @return string
*/
public function getIdentityCardPhotoFileName() {
return $this->identityCardPhotoFileName;
}
/**
* Set identityCardPhotoFileSize
*
* @param integer $identityCardPhotoFileSize
*
* @return IdentityCardPhoto
*/
public function setIdentityCardPhotoFileSize($identityCardPhotoFileSize) {
$this->identityCardPhotoFileSize = $identityCardPhotoFileSize;
return $this;
}
/**
* Get identityCardPhotoFileSize
*
* @return integer
*/
public function getIdentityCardPhotoFileSize() {
return $this->identityCardPhotoFileSize;
}
/**
* Set identityCardPhotoFileUpdatedAt
*
* @param DateTime $identityCardPhotoFileUpdatedAt
*
* @return IdentityCardPhoto
*/
public function setIdentityCardPhotoFileUpdatedAt($identityCardPhotoFileUpdatedAt) {
$this->identityCardPhotoFileUpdatedAt = $identityCardPhotoFileUpdatedAt;
return $this;
}
/**
* Get identityCardPhotoFileUpdatedAt
*
* @return DateTime
*/
public function getIdentityCardPhotoFileUpdatedAt() {
return $this->identityCardPhotoFileUpdatedAt;
}
/**
* Set user
*
* @param \App\Entity\User $user
*
* @return IdentityCardPhoto
*/
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 IdentityCard
*/
public function setIsDeleted($isDeleted)
{
$this->isDeleted = $isDeleted;
return $this;
}
/**
* Get isDeleted
*
* @return boolean
*/
public function getIsDeleted()
{
return $this->isDeleted;
}
/**
* @see \Serializable::serialize()
*/
public function serialize()
{
return serialize($this->id);
}
/**
* @see \Serializable::unserialize()
*/
public function unserialize($serialized)
{
$this->id = unserialize($serialized);
}
}