src/Entity/Membre.php line 16

  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\Timestamp;
  4. use App\Repository\MembreRepository;
  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(repositoryClassMembreRepository::class)]
  11. #[ORM\HasLifecycleCallbacks]
  12. #[Vich\Uploadable]
  13. class Membre
  14. {
  15.     use Timestamp;
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column]
  19.     private ?int $id null;
  20.     /**
  21.      * @var File|null
  22.      **/
  23.     #[Assert\Image(maxSize'50M'maxSizeMessage'Image trop volumineuse maximum 10Mb')]
  24.     #[Assert\Image(mimeTypes: ["image/jpeg""image/jpg""image/png"], mimeTypesMessage"Mauvais format d'image (jpeg, jpg et png)")]
  25.     #[Vich\UploadableField(mapping'membres'fileNameProperty'image')]
  26.     private $imageFile;
  27.     #[ORM\Column(length255nullabletrue)]
  28.     private ?string $image null;
  29.     #[ORM\Column(length80)]
  30.     private ?string $nom null;
  31.     #[ORM\Column(length80nullabletrue)]
  32.     private ?string $fonction null;
  33.     #[ORM\Column]
  34.     private ?bool $online null;
  35.     public function getId(): ?int
  36.     {
  37.         return $this->id;
  38.     }
  39.     public function getImage(): ?string
  40.     {
  41.         return $this->image;
  42.     }
  43.     public function setImage(?string $image): self
  44.     {
  45.         $this->image $image;
  46.         return $this;
  47.     }
  48.     public function getNom(): ?string
  49.     {
  50.         return $this->nom;
  51.     }
  52.     public function setNom(string $nom): self
  53.     {
  54.         $this->nom $nom;
  55.         return $this;
  56.     }
  57.     public function getFonction(): ?string
  58.     {
  59.         return $this->fonction;
  60.     }
  61.     public function setFonction(?string $fonction): self
  62.     {
  63.         $this->fonction $fonction;
  64.         return $this;
  65.     }
  66.     public function isOnline(): ?bool
  67.     {
  68.         return $this->online;
  69.     }
  70.     public function setOnline(bool $online): self
  71.     {
  72.         $this->online $online;
  73.         return $this;
  74.     }
  75.     /**
  76.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
  77.      */
  78.     public function setImageFile(?File $imageFile null): void
  79.     {
  80.         $this->imageFile $imageFile;
  81.         if (null !== $imageFile) {
  82.             // It is required that at least one field changes if you are using doctrine
  83.             // otherwise the event listeners won't be called and the file is lost
  84.             $this->setUpdated(new \DateTimeImmutable());
  85.         }
  86.     }
  87.     public function getImageFile(): ?File
  88.     {
  89.         return $this->imageFile;
  90.     }
  91.     public function __toString()
  92.     {
  93.         return $this->getNom();
  94.     }
  95. }