src/Entity/Slider.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use App\Repository\SliderRepository;
  5. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. use Symfony\Component\HttpFoundation\File\UploadedFile;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. /**
  10.  * @ORM\Entity(repositoryClass=SliderRepository::class)
  11.  * @Vich\Uploadable
  12.  */
  13. class Slider
  14. {
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\Column(type="string", length=255, nullable=true)
  23.      */
  24.     private $photo;
  25.     /**
  26.      * @ORM\Column(type="string", length=255, nullable=true)
  27.      */
  28.     private $lien;
  29.     /**
  30.      * @ORM\Column(type="boolean")
  31.      */
  32.     private $isPharmacie false;
  33.     /**
  34.      * @ORM\Column(type="boolean")
  35.      */
  36.     private $isGrossiste false;
  37.     /**
  38.      * @ORM\Column(type="boolean")
  39.      */
  40.     private $isPrescripteur false;
  41.     /**
  42.      * @ORM\ManyToOne(targetEntity=Laboratoire::class, inversedBy="sliders")
  43.      */
  44.     private $laboratoire;
  45.     /**
  46.      * @ORM\Column(type="datetime", nullable=true)
  47.      */
  48.     private $updatedAt;
  49.     /**
  50.      * @Vich\UploadableField(mapping="slider_image", fileNameProperty="photo")
  51.      * @var File|null
  52.      * @Assert\Image(
  53.      * mimeTypes = {"image/jpeg", "image/gif", "image/png", "image/jpg"},
  54.      * )
  55.      */
  56.     private $imageFile;
  57.     public function getId(): ?int
  58.     {
  59.         return $this->id;
  60.     }
  61.     public function getPhoto(): ?string
  62.     {
  63.         return $this->photo;
  64.     }
  65.     public function setPhoto(?string $photo): self
  66.     {
  67.         $this->photo $photo;
  68.         return $this;
  69.     }
  70.     public function getLien(): ?string
  71.     {
  72.         return $this->lien;
  73.     }
  74.     public function setLien(?string $lien): self
  75.     {
  76.         $this->lien $lien;
  77.         return $this;
  78.     }
  79.     public function getIsPharmacie(): ?bool
  80.     {
  81.         return $this->isPharmacie;
  82.     }
  83.     public function setIsPharmacie(bool $isPharmacie): self
  84.     {
  85.         $this->isPharmacie $isPharmacie;
  86.         return $this;
  87.     }
  88.     public function getIsGrossiste(): ?bool
  89.     {
  90.         return $this->isGrossiste;
  91.     }
  92.     public function setIsGrossiste(bool $isGrossiste): self
  93.     {
  94.         $this->isGrossiste $isGrossiste;
  95.         return $this;
  96.     }
  97.     public function getIsPrescripteur(): ?bool
  98.     {
  99.         return $this->isPrescripteur;
  100.     }
  101.     public function setIsPrescripteur(bool $isPrescripteur): self
  102.     {
  103.         $this->isPrescripteur $isPrescripteur;
  104.         return $this;
  105.     }
  106.     public function getLaboratoire(): ?Laboratoire
  107.     {
  108.         return $this->laboratoire;
  109.     }
  110.     public function setLaboratoire(?Laboratoire $laboratoire): self
  111.     {
  112.         $this->laboratoire $laboratoire;
  113.         return $this;
  114.     }
  115.     public function getUpdatedAt(): ?\DateTimeInterface
  116.     {
  117.         return $this->updatedAt;
  118.     }
  119.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  120.     {
  121.         $this->updatedAt $updatedAt;
  122.         return $this;
  123.     }
  124.     //pour l'upload image
  125.     public function setImageFile(?File $imageFile null):Slider
  126.     {
  127.         $this->imageFile $imageFile;
  128.         if ($imageFile instanceof UploadedFile) { 
  129.             $this->updatedAt = new \DateTime('now');
  130.         }
  131.         return $this;
  132.     }
  133.     public function getImageFile(): ?File
  134.     {
  135.         return $this->imageFile;
  136.     }
  137. }