src/Entity/Service.php line 17

  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\Timestamp;
  4. use App\Repository\ServiceRepository;
  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(repositoryClassServiceRepository::class)]
  12. #[ORM\HasLifecycleCallbacks]
  13. #[Vich\Uploadable]
  14. class Service
  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'services'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.     public function getId(): ?int
  41.     {
  42.         return $this->id;
  43.     }
  44.     public function getName(): ?string
  45.     {
  46.         return $this->name;
  47.     }
  48.     public function setName(string $name): static
  49.     {
  50.         $this->name $name;
  51.         return $this;
  52.     }
  53.     public function getSlug(): ?string
  54.     {
  55.         return $this->slug;
  56.     }
  57.     public function setSlug(string $slug): static
  58.     {
  59.         $this->slug $slug;
  60.         return $this;
  61.     }
  62.     public function getDescription(): ?string
  63.     {
  64.         return $this->description;
  65.     }
  66.     public function setDescription(?string $description): static
  67.     {
  68.         $this->description $description;
  69.         return $this;
  70.     }
  71.     public function __toString()
  72.     {
  73.         return $this->getName();
  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 isOnline(): ?bool
  85.     {
  86.         return $this->online;
  87.     }
  88.     public function setOnline(?bool $online): self
  89.     {
  90.         $this->online $online;
  91.         return $this;
  92.     }
  93.     public function getImage(): ?string
  94.     {
  95.         return $this->image;
  96.     }
  97.     public function setImage(?string $image): self
  98.     {
  99.         $this->image $image;
  100.         return $this;
  101.     }
  102.     /**
  103.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
  104.      */
  105.     public function setImageFile(?File $imageFile null): void
  106.     {
  107.         $this->imageFile $imageFile;
  108.         if (null !== $imageFile) {
  109.             // It is required that at least one field changes if you are using doctrine
  110.             // otherwise the event listeners won't be called and the file is lost
  111.             $this->setUpdated(new \DateTimeImmutable());
  112.         }
  113.     }
  114.     public function getImageFile(): ?File
  115.     {
  116.         return $this->imageFile;
  117.     }
  118. }