src/Entity/Formation.php line 17

  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\Timestamp;
  4. use App\Repository\FormationRepository;
  5. use Doctrine\DBAL\Types\Types;
  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(repositoryClassFormationRepository::class)]
  12. #[ORM\HasLifecycleCallbacks]
  13. #[Vich\Uploadable]
  14. class Formation
  15. {
  16.     use Timestamp;
  17.     #[ORM\Id]
  18.     #[ORM\GeneratedValue]
  19.     #[ORM\Column]
  20.     private ?int $id null;
  21.     /**
  22.      * @var File|null
  23.      **/
  24.     #[Assert\Image(maxSize'50M'maxSizeMessage'Image trop volumineuse maximum 10Mb')]
  25.     #[Assert\Image(mimeTypes: ["image/jpeg""image/jpg""image/png"], mimeTypesMessage"Mauvais format d'image (jpeg, jpg et png)")]
  26.     #[Vich\UploadableField(mapping'formations'fileNameProperty'image')]
  27.     private $imageFile;
  28.     #[ORM\Column(length255nullabletrue)]
  29.     private ?string $image null;
  30.     #[ORM\Column(length255)]
  31.     private ?string $name null;
  32.     #[ORM\Column(length255)]
  33.     private ?string $slug null;
  34.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  35.     private ?string $description null;
  36.     #[ORM\Column(nullabletrue)]
  37.     private ?int $position null;
  38.     #[ORM\Column(nullabletrue)]
  39.     private ?bool $online null;
  40.     #[ORM\Column(length255)]
  41.     private ?string $categories null;
  42.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  43.     private ?\DateTimeInterface $date null;
  44.     public function getId(): ?int
  45.     {
  46.         return $this->id;
  47.     }
  48.     public function getName(): ?string
  49.     {
  50.         return $this->name;
  51.     }
  52.     public function setName(string $name): static
  53.     {
  54.         $this->name $name;
  55.         return $this;
  56.     }
  57.     public function getSlug(): ?string
  58.     {
  59.         return $this->slug;
  60.     }
  61.     public function setSlug(string $slug): static
  62.     {
  63.         $this->slug $slug;
  64.         return $this;
  65.     }
  66.     public function getDescription(): ?string
  67.     {
  68.         return $this->description;
  69.     }
  70.     public function setDescription(?string $description): static
  71.     {
  72.         $this->description $description;
  73.         return $this;
  74.     }
  75.     public function getPosition(): ?int
  76.     {
  77.         return $this->position;
  78.     }
  79.     public function setPosition(?int $position): self
  80.     {
  81.         $this->position $position;
  82.         return $this;
  83.     }
  84.     public function __toString()
  85.     {
  86.         return $this->getName();
  87.     }
  88.     public function isOnline(): ?bool
  89.     {
  90.         return $this->online;
  91.     }
  92.     public function setOnline(?bool $online): self
  93.     {
  94.         $this->online $online;
  95.         return $this;
  96.     }
  97.     public function getImage(): ?string
  98.     {
  99.         return $this->image;
  100.     }
  101.     public function setImage(?string $image): self
  102.     {
  103.         $this->image $image;
  104.         return $this;
  105.     }
  106.     /**
  107.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
  108.      */
  109.     public function setImageFile(?File $imageFile null): void
  110.     {
  111.         $this->imageFile $imageFile;
  112.         if (null !== $imageFile) {
  113.             // It is required that at least one field changes if you are using doctrine
  114.             // otherwise the event listeners won't be called and the file is lost
  115.             $this->setUpdated(new \DateTimeImmutable());
  116.         }
  117.     }
  118.     public function getImageFile(): ?File
  119.     {
  120.         return $this->imageFile;
  121.     }
  122.     public function getCategories(): ?string
  123.     {
  124.         return $this->categories;
  125.     }
  126.     public function setCategories(string $categories): static
  127.     {
  128.         $this->categories $categories;
  129.         return $this;
  130.     }
  131.     public function getDate(): ?\DateTimeInterface
  132.     {
  133.         return $this->date;
  134.     }
  135.     public function setDate(?\DateTimeInterface $date): static
  136.     {
  137.         $this->date $date;
  138.         return $this;
  139.     }
  140. }