src/Entity/IdentityCardPhoto.php line 17

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