src/Entity/Fap.php line 15

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\FapRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\HttpFoundation\File\File;
  7. use Symfony\Component\HttpFoundation\File\UploadedFile;
  8. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. #[ORM\Entity(repositoryClassFapRepository::class)]
  11. #[Vich\Uploadable]
  12. class Fap
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     private ?int $id null;
  18.     #[ORM\Column(length255nullabletrue)]
  19.     private ?string $picture null;
  20.     #[Vich\UploadableField(mapping'fap'fileNameProperty'picture')]
  21.     #[Assert\File(
  22.         maxSize'2048k',
  23.         extensions: ['jpg','jpeg','png'],
  24.         extensionsMessage'Please upload a valid Image',
  25.     )]
  26.     private ?File $pictureFile null;
  27.     #[ORM\Column(length255)]
  28.     private ?string $bnbAddress null;
  29.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  30.     private \DateTimeInterface $createdAt;
  31.     #[ORM\Column]
  32.     private bool $validated false;
  33.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  34.     private ?\DateTimeInterface $updatedAt null;
  35.     public function  __construct()
  36.     {
  37.         $this->createdAt = new \DateTime();
  38.         $this->updatedAt = new \DateTime();
  39.     }
  40.     public function getId(): ?int
  41.     {
  42.         return $this->id;
  43.     }
  44.     public function getPicture(): ?string
  45.     {
  46.         return $this->picture;
  47.     }
  48.     public function setPicture(?string $picture): self
  49.     {
  50.         $this->picture $picture;
  51.         return $this;
  52.     }
  53.     public function getBnbAddress(): ?string
  54.     {
  55.         return $this->bnbAddress;
  56.     }
  57.     public function setBnbAddress(string $bnbAddress): self
  58.     {
  59.         $this->bnbAddress $bnbAddress;
  60.         return $this;
  61.     }
  62.     public function getCreatedAt(): ?\DateTimeInterface
  63.     {
  64.         return $this->createdAt;
  65.     }
  66.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  67.     {
  68.         $this->createdAt $createdAt;
  69.         return $this;
  70.     }
  71.     public function isValidated(): ?bool
  72.     {
  73.         return $this->validated;
  74.     }
  75.     public function setValidated(bool $validated): self
  76.     {
  77.         $this->validated $validated;
  78.         return $this;
  79.     }
  80.     /**
  81.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  82.      * of 'UploadedFile' is injected into this setter to trigger the update. If this
  83.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  84.      * must be able to accept an instance of 'File' as the bundle will inject one here
  85.      * during Doctrine hydration.
  86.      *
  87.      * @param File|UploadedFile|null $pictureFile
  88.      */
  89.     public function setPictureFile(?File $pictureFile null): void
  90.     {
  91.         $this->pictureFile $pictureFile;
  92.         if (null !== $pictureFile) {
  93.             // It is required that at least one field changes if you are using doctrine
  94.             // otherwise the event listeners won't be called and the file is lost
  95.             $this->updatedAt = new \DateTimeImmutable();
  96.         }
  97.     }
  98.     public function getPictureFile(): ?File
  99.     {
  100.         return $this->pictureFile;
  101.     }
  102.     public function getUpdatedAt(): ?\DateTimeInterface
  103.     {
  104.         return $this->updatedAt;
  105.     }
  106.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  107.     {
  108.         $this->updatedAt $updatedAt;
  109.         return $this;
  110.     }
  111. }