src/Entity/Slider.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use DateTime;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\HttpFoundation\File\File;
  6. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. /**
  9.  * @ORM\Entity(repositoryClass="App\Repository\App\SliderRepository")
  10.  *
  11.  * @Vich\Uploadable
  12.  */
  13. class Slider
  14. {
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     protected int $id;
  21.     /**
  22.      * @ORM\Column(type="string", length=255, nullable=false)
  23.      */
  24.     protected string $sliderName;
  25.     /**
  26.      * @ORM\Column(type="string", length=255)
  27.      */
  28.     protected string $title;
  29.     /**
  30.      * @ORM\Column(type="datetime", nullable=true)
  31.      */
  32.     protected ?\DateTimeInterface $startDate;
  33.     /**
  34.      * @ORM\Column(type="datetime", nullable=true)
  35.      */
  36.     protected ?\DateTimeInterface $endDate;
  37.     /**
  38.      * @ORM\Column(type="text", nullable=true)
  39.      */
  40.     protected ?string $text;
  41.     /**
  42.      * @Vich\UploadableField(mapping="consumption_slider_image", fileNameProperty="image")
  43.      * @Assert\File(
  44.      *     mimeTypes = {"image/jpg", "image/jpeg", "image/png"},
  45.      *     mimeTypesMessage = "Vous ne pouvez insérer que des images au format jpg/png"
  46.      * )
  47.      *
  48.      * @var File
  49.      */
  50.     protected $imageFile;
  51.     /**
  52.      * @ORM\Column (type="integer", nullable=true)
  53.      * @Assert\GreaterThanOrEqual (0)
  54.      */
  55.     protected ?int $priority;
  56.     /**
  57.      * @ORM\Column (type="string", length=255, nullable=true)
  58.      */
  59.     protected ?string $linkUrl;
  60.     /**
  61.      * @ORM\Column(type="text", length=10, nullable=true)
  62.      * @Assert\Choice ({"_blank", "_self"})
  63.      */
  64.     protected ?string $linkTarget;
  65.     /**
  66.      * @ORM\Column(type="string", length=255, nullable=true)
  67.      */
  68.     private ?string $image;
  69.     /**
  70.      * @ORM\Column(type="string", length=255, nullable=true)
  71.      */
  72.     private ?string $linkDescription;
  73.     /**
  74.      * @ORM\Column(type="datetime", nullable=true)
  75.      */
  76.     private ?DateTime $updatedAt;
  77.     public function getId(): ?int
  78.     {
  79.         return $this->id;
  80.     }
  81.     /**
  82.      * @return Slider
  83.      */
  84.     public function setId(int $id): self
  85.     {
  86.         $this->id $id;
  87.         return $this;
  88.     }
  89.     public function getSliderName(): string
  90.     {
  91.         return $this->sliderName;
  92.     }
  93.     public function setSliderName(string $sliderName): void
  94.     {
  95.         $this->sliderName $sliderName;
  96.     }
  97.     public function getTitle(): ?string
  98.     {
  99.         return $this->title;
  100.     }
  101.     public function setTitle(string $title): self
  102.     {
  103.         $this->title $title;
  104.         return $this;
  105.     }
  106.     public function getStartDate(): ?\DateTimeInterface
  107.     {
  108.         return $this->startDate;
  109.     }
  110.     public function setStartDate(?\DateTimeInterface $startDate): self
  111.     {
  112.         $this->startDate $startDate;
  113.         return $this;
  114.     }
  115.     public function getEndDate(): ?\DateTimeInterface
  116.     {
  117.         return $this->endDate;
  118.     }
  119.     public function setEndDate(?\DateTimeInterface $endDate): self
  120.     {
  121.         $this->endDate $endDate;
  122.         return $this;
  123.     }
  124.     public function getText(): ?string
  125.     {
  126.         return $this->text;
  127.     }
  128.     public function setText(?string $text): self
  129.     {
  130.         $this->text $text;
  131.         return $this;
  132.     }
  133.     public function getImage(): ?string
  134.     {
  135.         return $this->image;
  136.     }
  137.     public function setImage(?string $image): self
  138.     {
  139.         $this->image $image;
  140.         return $this;
  141.     }
  142.     public function getImageFile(): ?File
  143.     {
  144.         return $this->imageFile;
  145.     }
  146.     /**
  147.      * @return Dashboard
  148.      * @throws \Exception
  149.      *
  150.      */
  151.     public function setImageFile(?File $imageFile): self
  152.     {
  153.         $this->imageFile $imageFile;
  154.         if ($imageFile) {
  155.             $this->updatedAt = new \DateTime('now');
  156.         }
  157.         return $this;
  158.     }
  159.     public function getPriority(): ?int
  160.     {
  161.         return $this->priority;
  162.     }
  163.     public function setPriority(?int $priority): self
  164.     {
  165.         $this->priority $priority;
  166.         return $this;
  167.     }
  168.     public function getLinkUrl(): ?string
  169.     {
  170.         return $this->linkUrl;
  171.     }
  172.     public function setLinkUrl($linkUrl): self
  173.     {
  174.         $this->linkUrl $linkUrl;
  175.         return $this;
  176.     }
  177.     public function getLinkTarget(): ?string
  178.     {
  179.         return $this->linkTarget;
  180.     }
  181.     public function setLinkTarget($linkTarget): self
  182.     {
  183.         $this->linkTarget $linkTarget;
  184.         return $this;
  185.     }
  186.     public function getLinkDescription(): ?string
  187.     {
  188.         return $this->linkDescription;
  189.     }
  190.     public function setLinkDescription(?string $linkDescription): self
  191.     {
  192.         $this->linkDescription $linkDescription;
  193.         return $this;
  194.     }
  195. }