src/Entity/Evenement.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\EvenementRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Symfony\Component\HttpFoundation\File\File;
  8. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. #[ORM\Entity(repositoryClassEvenementRepository::class)]
  12. #[Vich\Uploadable]
  13. class Evenement
  14. {
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column]
  18.     private ?int $id null;
  19.     #[ORM\Column(length255nullabletrue)]
  20.     #[Assert\NotBlank (message:"Le champ ne peut pas être vide.")]
  21.     private ?string $wording null;
  22.     #[ORM\Column(length255nullabletrue)]
  23.     #[Assert\NotBlank (message:"Le champ ne peut pas être vide.")]
  24.     private ?string $description null;
  25.     #[ORM\Column(length255nullabletrue)]
  26.     #[Assert\NotBlank(message"Le champ ne peut pas être vide.")]
  27.     private ?string $descriptionCourte null;
  28.     #[ORM\Column(length255nullabletrue)]
  29.     private ?string $image null;
  30.     #[Vich\UploadableField(mapping'event'fileNameProperty'image')]
  31.     #[Assert\Image(
  32.         maxSize'10240k',
  33.         mimeTypes: ['image/*'],
  34.         mimeTypesMessage"Veuillez donner une image"
  35.     )]
  36.     private $imageFile null;
  37.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  38.     private ?\DateTimeInterface $dateDebut null;
  39.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  40.     private ?\DateTimeInterface $dateFin null;
  41.     #[ORM\OneToMany(mappedBy'evenement'targetEntityImages::class,cascade: ["persist"])]
  42.     private Collection $images;
  43.     #[ORM\Column(length255nullabletrue)]
  44.     private ?string $video null;
  45.     #[Vich\UploadableField(mapping'event'fileNameProperty'video')]
  46.     private $videoFile null;
  47.     #[ORM\Column(type'datetime'nullabletrue)]
  48.     private $updatedAt null;
  49.     public function __construct()
  50.     {
  51.         $this->images = new ArrayCollection();
  52.         $this->updatedAt = new \DateTime('now');
  53.     }
  54.     public function getId(): ?int
  55.     {
  56.         return $this->id;
  57.     }
  58.     public function setImageFile(File $imageFile null)
  59.     {
  60.         $this->imageFile $imageFile;
  61.         if ($imageFile) {
  62.             $this->updatedAt = new \DateTime('now');
  63.         }
  64.     }
  65.     public function getImageFile()
  66.     {
  67.         return $this->imageFile;
  68.     }
  69.     public function getWording(): ?string
  70.     {
  71.         return $this->wording;
  72.     }
  73.     public function setWording(?string $wording): self
  74.     {
  75.         $this->wording $wording;
  76.         return $this;
  77.     }
  78.     public function getDescription(): ?string
  79.     {
  80.         return $this->description;
  81.     }
  82.     public function setDescription(?string $description): self
  83.     {
  84.         $this->description $description;
  85.         return $this;
  86.     }
  87.     public function getImage(): ?string
  88.     {
  89.         return $this->image;
  90.     }
  91.     public function setImage(?string $image): self
  92.     {
  93.         $this->image $image;
  94.         return $this;
  95.     }
  96.     public function getDateDebut(): ?\DateTimeInterface
  97.     {
  98.         return $this->dateDebut;
  99.     }
  100.     public function setDateDebut(?\DateTimeInterface $dateDebut): self
  101.     {
  102.         $this->dateDebut $dateDebut;
  103.         return $this;
  104.     }
  105.     public function getDateFin(): ?\DateTimeInterface
  106.     {
  107.         return $this->dateFin;
  108.     }
  109.     public function setDateFin(?\DateTimeInterface $dateFin): self
  110.     {
  111.         $this->dateFin $dateFin;
  112.         return $this;
  113.     }
  114.     /**
  115.      * @return Collection<int, Images>
  116.      */
  117.     public function getImages(): Collection
  118.     {
  119.         return $this->images;
  120.     }
  121.     public function addImage(Images $image): self
  122.     {
  123.         if (!$this->images->contains($image)) {
  124.             $this->images->add($image);
  125.             $image->setEvenement($this);
  126.         }
  127.         return $this;
  128.     }
  129.     public function removeImage(Images $image): self
  130.     {
  131.         if ($this->images->removeElement($image)) {
  132.             // set the owning side to null (unless already changed)
  133.             if ($image->getEvenement() === $this) {
  134.                 $image->setEvenement(null);
  135.             }
  136.         }
  137.         return $this;
  138.     }
  139.     public function getVideo(): ?string
  140.     {
  141.         return $this->video;
  142.     }
  143.     public function setVideo(?string $video): self
  144.     {
  145.         $this->video $video;
  146.         return $this;
  147.     }
  148.     public function setVideoFile(File $videoFile null)
  149.     {
  150.         $this->videoFile $videoFile;
  151.     }
  152.     public function getVideoFile()
  153.     {
  154.         return $this->videoFile;
  155.     }
  156.     public function getUpdatedAt(): ?\DateTimeInterface
  157.     {
  158.         return $this->updatedAt;
  159.     }
  160.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): static
  161.     {
  162.         $this->updatedAt $updatedAt;
  163.         return $this;
  164.     }
  165.     public function getDescriptionCourte(): ?string
  166.     {
  167.         return $this->descriptionCourte;
  168.     }
  169.     public function setDescriptionCourte(?string $descriptionCourte): static
  170.     {
  171.         $this->descriptionCourte $descriptionCourte;
  172.         return $this;
  173.     }
  174. }