src/Entity/Event.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\EventRepository;
  4. use DateTime;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Symfony\Component\HttpFoundation\File\UploadedFile;
  10. #[ORM\Entity(repositoryClassEventRepository::class)]
  11. #[Vich\Uploadable]
  12. class Event
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column(type'integer')]
  17.     private $id;
  18.     #[ORM\Column(type'string'length255)]
  19.     private $name;
  20.     #[ORM\Column(type'datetime')]
  21.     private $created_at;
  22.     #[ORM\Column(type'datetime')]
  23.     private $updated_at;
  24.     #[ORM\Column(type'datetime')]
  25.     private $date;
  26.     #[ORM\Column(type'text')]
  27.     private $description;
  28.     #[ORM\Column(type'string'length255)]
  29.     private $telephone;
  30.     #[ORM\Column(type'string'length255)]
  31.     private $ville;
  32.     #[ORM\Column(type'string'length255)]
  33.     private $link;
  34.     #[ORM\Column(type'string'length255)]
  35.     private $filename;
  36.     #[Vich\UploadableField(mapping"event"fileNameProperty"filename")]
  37.     #[Assert\Image(
  38.         mimeTypes: ['image/jpeg''image/png''image/jpg''image/gif'],
  39.         mimeTypesMessage"Les formats d'images acceptés sont : .jpeg .png .jpg and .gif"
  40.     )]
  41.     private ?File $imageFile null;
  42.     #[ORM\Column(type'integer'nullabletrue)]
  43.     private $position;
  44.     
  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 getName(): ?string
  55.     {
  56.         return $this->name;
  57.     }
  58.     public function setName(string $name): self
  59.     {
  60.         $this->name $name;
  61.         return $this;
  62.     }
  63.     public function getCreatedAt(): ?\DateTimeInterface
  64.     {
  65.         return $this->created_at;
  66.     }
  67.     public function setCreatedAt(\DateTimeInterface $created_at): self
  68.     {
  69.         $this->created_at $created_at;
  70.         return $this;
  71.     }
  72.     public function getUpdatedAt(): ?\DateTimeInterface
  73.     {
  74.         return $this->updated_at;
  75.     }
  76.     public function setUpdatedAt(\DateTimeInterface $updated_at): self
  77.     {
  78.         $this->updated_at $updated_at;
  79.         return $this;
  80.     }
  81.     public function getDate(): ?\DateTimeInterface
  82.     {
  83.         return $this->date;
  84.     }
  85.     public function setDate(\DateTimeInterface $date): self
  86.     {
  87.         $this->date $date;
  88.         return $this;
  89.     }
  90.     public function getDescription(): ?string
  91.     {
  92.         return $this->description;
  93.     }
  94.     public function setDescription(string $description): self
  95.     {
  96.         $this->description $description;
  97.         return $this;
  98.     }
  99.     public function getTelephone(): ?string
  100.     {
  101.         return $this->telephone;
  102.     }
  103.     public function setTelephone(string $telephone): self
  104.     {
  105.         $this->telephone $telephone;
  106.         return $this;
  107.     }
  108.     public function getVille(): ?string
  109.     {
  110.         return $this->ville;
  111.     }
  112.     public function setVille(string $ville): self
  113.     {
  114.         $this->ville $ville;
  115.         return $this;
  116.     }
  117.     public function getLink(): ?string
  118.     {
  119.         return $this->link;
  120.     }
  121.     public function setLink(string $link): self
  122.     {
  123.         $this->link $link;
  124.         return $this;
  125.     }
  126.     public function getFilename(): ?string
  127.     {
  128.         return $this->filename;
  129.     }
  130.     public function setFilename(string $filename): self
  131.     {
  132.         $this->filename $filename;
  133.         return $this;
  134.     }
  135.     /**
  136.      * @return null|File
  137.      */
  138.     public function getImageFile(): ?File
  139.     {
  140.         return $this->imageFile;
  141.     }
  142.     /**
  143.      * @param null|File $imageFile
  144.      */
  145.     public function setImageFile(?File $imageFile): self
  146.     {
  147.         $this->imageFile $imageFile;
  148.         if ($this->imageFile instanceof UploadedFile) {
  149.             $this->updated_at = new \DateTime('now');
  150.         }
  151.         return $this;
  152.     }
  153.     public function getPosition(): ?int
  154.     {
  155.         return $this->position;
  156.     }
  157.     public function setPosition(?int $position): self
  158.     {
  159.         $this->position $position;
  160.         return $this;
  161.     }
  162. }