src/Entity/Actualite.php line 17

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