src/Entity/Realisation.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\RealisationRepository;
  4. use DateTime;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\HttpFoundation\File\File;
  7. use Symfony\Component\HttpFoundation\File\UploadedFile;
  8. use Symfony\UX\Turbo\Attribute\Broadcast;
  9. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. #[ORM\Entity(repositoryClassRealisationRepository::class)]
  12. #[Broadcast]
  13. #[Vich\Uploadable]
  14. class Realisation
  15. {
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column(type'integer')]
  19.     private $id;
  20.     #[ORM\Column(type'string'length255)]
  21.     private $name;
  22.     #[ORM\Column(type'string'length255nullabletrue)]
  23.     private $position;
  24.     #[ORM\Column(type'string'length255nullabletrue)]
  25.     private $description;
  26.     #[ORM\Column(type'string'length255nullabletrue)]
  27.     private $pictureFilename;
  28.     /**
  29.      * @var File|null
  30.      */
  31.     #[Vich\UploadableField(mapping"realisation"fileNameProperty"pictureFilename")]
  32.     #[Assert\Image(
  33.         mimeTypes: ["image/jpeg""image/png""image/jpg""image/gif"],
  34.         mimeTypesMessage"Les formats d'images acceptés sont : .jpeg .jpg .png .gif"
  35.     )]
  36.     private $pictureFile;
  37.     #[ORM\Column(type'datetime')]
  38.     private $created_at;
  39.     #[ORM\Column(type'datetime')]
  40.     private $updated_at;
  41.     public function __construct()
  42.     {
  43.         $this->created_at = new DateTime('now');
  44.         $this->updated_at = new DateTime('now');
  45.     }
  46.     public function getId(): ?int
  47.     {
  48.         return $this->id;
  49.     }
  50.     public function getName(): ?string
  51.     {
  52.         return $this->name;
  53.     }
  54.     public function setName(string $name): self
  55.     {
  56.         $this->name $name;
  57.         return $this;
  58.     }
  59.     public function getPosition(): ?string
  60.     {
  61.         return $this->position;
  62.     }
  63.     public function setPosition(?string $position): self
  64.     {
  65.         $this->position $position;
  66.         return $this;
  67.     }
  68.     public function getDescription(): ?string
  69.     {
  70.         return $this->description;
  71.     }
  72.     public function setDescription(?string $description): self
  73.     {
  74.         $this->description $description;
  75.         return $this;
  76.     }
  77.     public function getPictureFilename(): ?string
  78.     {
  79.         return $this->pictureFilename;
  80.     }
  81.     public function setPictureFilename(?string $pictureFilename): self
  82.     {
  83.         $this->pictureFilename $pictureFilename;
  84.         return $this;
  85.     }
  86.     /**
  87.      * @return null|File
  88.      */
  89.     public function getPictureFile(): ?File
  90.     {
  91.         return $this->pictureFile;
  92.     }
  93.     /**
  94.      * @param null|File $pictureFile
  95.      * @return Realisation
  96.      */
  97.     public function setPictureFile(?File $pictureFile): self
  98.     {
  99.         $this->pictureFile $pictureFile;
  100.         if ($this->pictureFile instanceof UploadedFile) {
  101.             $this->updated_at = new DateTime('now');
  102.         }
  103.         return $this;
  104.     }
  105.     public function getCreatedAt(): ?\DateTimeInterface
  106.     {
  107.         return $this->created_at;
  108.     }
  109.     public function setCreatedAt(\DateTimeInterface $created_at): self
  110.     {
  111.         $this->created_at $created_at;
  112.         return $this;
  113.     }
  114.     public function getUpdatedAt(): ?\DateTimeInterface
  115.     {
  116.         return $this->updated_at;
  117.     }
  118.     public function setUpdatedAt(\DateTimeInterface $updated_at): self
  119.     {
  120.         $this->updated_at $updated_at;
  121.         return $this;
  122.     }
  123. }