src/Entity/Temoignage.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\TemoignageRepository;
  4. use Cocur\Slugify\Slugify;
  5. use DateTime;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\HttpFoundation\File\File;
  8. use Symfony\Component\HttpFoundation\File\UploadedFile;
  9. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. #[ORM\Entity(repositoryClassTemoignageRepository::class)]
  12. #[Vich\Uploadable]
  13. class Temoignage
  14. {
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column(type'integer')]
  18.     private $id;
  19.     #[ORM\Column(type'string'length255)]
  20.     private $prenom;
  21.     #[ORM\Column(type'string'length255)]
  22.     private $metier;
  23.     #[ORM\Column(type'text')]
  24.     #[Assert\Length(
  25.         min2,
  26.         max500,
  27.         minMessage'Votre prévisualisation doit au moins faire {{ limit }} caractères de long',
  28.         maxMessage'Votre prévisualisation ne doit pas faire plus de {{ limit }} caractères de long',
  29.     )]
  30.     private $citation;
  31.     #[ORM\Column(type'string'length255)]
  32.     private $filename;
  33.     #[Vich\UploadableField(mapping"temoignages"fileNameProperty"filename")]
  34.     #[Assert\Image(
  35.         mimeTypes: ['image/jpeg''image/png''image/jpg''image/gif'],
  36.         mimeTypesMessage"Les formats d'images acceptés sont : .jpeg .png .jpg and .gif"
  37.     )]
  38.     private ?File $imageFile null;
  39.     #[ORM\Column(type'datetime')]
  40.     private $created_at;
  41.     #[ORM\Column(type'datetime')]
  42.     private $updated_at;
  43.     #[ORM\Column(type'text')]
  44.     private $largeCitation;
  45.     public function __construct()
  46.     {
  47.         $this->created_at = new DateTime('now');
  48.         $this->updated_at = new DateTime('now');
  49.     }
  50.     public function getId(): ?int
  51.     {
  52.         return $this->id;
  53.     }
  54.     public function getSlug()
  55.     {
  56.         return (new Slugify())->slugify($this->prenom);
  57.     }
  58.     public function getPrenom(): ?string
  59.     {
  60.         return $this->prenom;
  61.     }
  62.     public function setPrenom(string $prenom): self
  63.     {
  64.         $this->prenom $prenom;
  65.         return $this;
  66.     }
  67.     public function getMetier(): ?string
  68.     {
  69.         return $this->metier;
  70.     }
  71.     public function setMetier(string $metier): self
  72.     {
  73.         $this->metier $metier;
  74.         return $this;
  75.     }
  76.     /**
  77.      * @return null|File
  78.      */
  79.     public function getImageFile(): ?File
  80.     {
  81.         return $this->imageFile;
  82.     }
  83.     /**
  84.      * @param null|File $imageFile
  85.      */
  86.     public function setImageFile(?File $imageFile): self
  87.     {
  88.         $this->imageFile $imageFile;
  89.         if ($this->imageFile instanceof UploadedFile) {
  90.             $this->updated_at = new \DateTime('now');
  91.         }
  92.         return $this;
  93.     }
  94.     public function getCitation(): ?string
  95.     {
  96.         return $this->citation;
  97.     }
  98.     public function setCitation(string $citation): self
  99.     {
  100.         $this->citation $citation;
  101.         return $this;
  102.     }
  103.     public function getFilename(): ?string
  104.     {
  105.         return $this->filename;
  106.     }
  107.     public function setFilename(string $filename): self
  108.     {
  109.         $this->filename $filename;
  110.         return $this;
  111.     }
  112.     public function getCreatedAt(): ?\DateTimeInterface
  113.     {
  114.         return $this->created_at;
  115.     }
  116.     public function setCreatedAt(\DateTimeInterface $created_at): self
  117.     {
  118.         $this->created_at $created_at;
  119.         return $this;
  120.     }
  121.     public function getUpdatedAt(): ?\DateTimeInterface
  122.     {
  123.         return $this->updated_at;
  124.     }
  125.     public function setUpdatedAt(\DateTimeInterface $updated_at): self
  126.     {
  127.         $this->updated_at $updated_at;
  128.         return $this;
  129.     }
  130.     public function getLargeCitation(): ?string
  131.     {
  132.         return $this->largeCitation;
  133.     }
  134.     public function setLargeCitation(string $largeCitation): self
  135.     {
  136.         $this->largeCitation $largeCitation;
  137.         return $this;
  138.     }
  139. }