src/Entity/Gos/Advert.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gos;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\HttpFoundation\File\File;
  5. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  6. /**
  7.  * @ORM\Entity(repositoryClass="App\Repository\Gos\AdvertRepository")
  8.  * @ORM\HasLifecycleCallbacks()
  9.  * @Vich\Uploadable()
  10.  */
  11. class Advert
  12. {
  13.     /**
  14.      * @ORM\Id()
  15.      * @ORM\GeneratedValue()
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="integer")
  21.      */
  22.     private $position;
  23.     /**
  24.      * @ORM\Column(type="datetime")
  25.      */
  26.     private $createdAt;
  27.     /**
  28.      * @ORM\Column(type="datetime", nullable=true)
  29.      */
  30.     private $updatedAt;
  31.     /**
  32.      * @Vich\UploadableField(mapping="advert_image", fileNameProperty="imageFilename")
  33.      */
  34.     private $image;
  35.     /**
  36.      * @ORM\Column(type="string", length=255, nullable=true)
  37.      */
  38.     private $imageFilename;
  39.     /**
  40.      * @ORM\Column(type="boolean")
  41.      */
  42.     private $isActive;
  43.     /**
  44.      * @ORM\Column(type="string", length=255)
  45.      */
  46.     private $name;
  47.     /**
  48.      * @ORM\ManyToOne(targetEntity=Coupon::class)
  49.      */
  50.     private $coupon;
  51.     /** @ORM\PrePersist() */
  52.     public function onPrePersist()
  53.     {
  54.         $this->createdAt = new \DateTime();
  55.     }
  56.     /** @ORM\PreUpdate() */
  57.     public function onPreUpdate()
  58.     {
  59.         $this->updatedAt = new \DateTime();
  60.     }
  61.     public function getId(): ?int
  62.     {
  63.         return $this->id;
  64.     }
  65.     public function getPosition(): ?int
  66.     {
  67.         return $this->position;
  68.     }
  69.     public function setPosition(int $position): self
  70.     {
  71.         $this->position $position;
  72.         return $this;
  73.     }
  74.     public function getCreatedAt(): ?\DateTimeInterface
  75.     {
  76.         return $this->createdAt;
  77.     }
  78.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  79.     {
  80.         $this->createdAt $createdAt;
  81.         return $this;
  82.     }
  83.     public function getUpdatedAt(): ?\DateTimeInterface
  84.     {
  85.         return $this->updatedAt;
  86.     }
  87.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  88.     {
  89.         $this->updatedAt $updatedAt;
  90.         return $this;
  91.     }
  92.     public function setImage(?File $image null): void
  93.     {
  94.         $this->image $image;
  95.         if ($image !== null)
  96.         {
  97.             $this->updatedAt = new \DateTimeImmutable();
  98.         }
  99.     }
  100.     public function getImage(): ?File
  101.     {
  102.         return $this->image;
  103.     }
  104.     public function getImageFilename(): ?string
  105.     {
  106.         return $this->imageFilename;
  107.     }
  108.     public function setImageFilename(?string $imageFilename): self
  109.     {
  110.         $this->imageFilename $imageFilename;
  111.         return $this;
  112.     }
  113.     public function getIsActive(): ?bool
  114.     {
  115.         return $this->isActive;
  116.     }
  117.     public function setIsActive(bool $isActive): self
  118.     {
  119.         $this->isActive $isActive;
  120.         return $this;
  121.     }
  122.     public function getName(): ?string
  123.     {
  124.         return $this->name;
  125.     }
  126.     public function setName(string $name): self
  127.     {
  128.         $this->name $name;
  129.         return $this;
  130.     }
  131.     public function getCoupon(): ?Coupon
  132.     {
  133.         return $this->coupon;
  134.     }
  135.     public function setCoupon(?Coupon $coupon): self
  136.     {
  137.         $this->coupon $coupon;
  138.         return $this;
  139.     }
  140. }