src/Entity/StoreEmployee.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\StoreEmployeeRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use DateTime;
  6. use Symfony\Component\HttpFoundation\File\File;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  9. /**
  10.  * @ORM\Entity(repositoryClass=StoreEmployeeRepository::class)
  11.  * @Vich\Uploadable
  12.  */
  13. class StoreEmployee
  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)
  23.      */
  24.     private $firstname;
  25.     /**
  26.      * @ORM\Column(type="string", length=255)
  27.      */
  28.     private $lastname;
  29.     /**
  30.      * @ORM\Column(type="string", length=255)
  31.      */
  32.     private $speciality;
  33.     /**
  34.      * @ORM\ManyToOne(targetEntity=StorePage::class, inversedBy="employees")
  35.      * @ORM\JoinColumn(nullable=false)
  36.      */
  37.     private $storePage;
  38.     /**
  39.      * @ORM\Column(type="string", length=255, nullable=true)
  40.      */
  41.     private $picturePath;
  42.     /**
  43.      * @assert\File( mimeTypes = {"image/jpeg", "image/png", "image/gif", "image/jpg","image/webp"})
  44.      * @Vich\UploadableField(mapping="employee_images", fileNameProperty="picturePath")
  45.      * @var File
  46.      */
  47.     private $pictureFile;
  48.     /**
  49.      * @ORM\Column(type="datetime", nullable=true)
  50.      */
  51.     private $updatedAt;
  52.     /**
  53.      * @return mixed
  54.      */
  55.     public function getUpdatedAt(): ?\DateTimeInterface
  56.     {
  57.         return $this->updatedAt;
  58.     }
  59.     /**
  60.      * @param mixed $updatedAt
  61.      */
  62.     public function setUpdatedAt(?\DateTimeInterface  $updatedAt): self
  63.     {
  64.         $this->updatedAt $updatedAt;
  65.         return $this;
  66.     }
  67.     public function getPicturePath()
  68.     {
  69.         return $this->picturePath;
  70.     }
  71.     public function setPicturePath(?string $picturePath)
  72.     {
  73.         $this->picturePath $picturePath;
  74.         return $this;
  75.     }
  76.     /**
  77.      * @return bool
  78.      */
  79.     public function hasPicture(){
  80.         return !is_null($this->picturePath);
  81.     }
  82.     public function setPictureFile(File $picturePath null)
  83.     {
  84.         $this->pictureFile $picturePath;
  85.         if ($picturePath){
  86.             $this->updatedAt = new \DateTime('now');
  87.         }
  88.     }
  89.     public function getPictureFile()
  90.     {
  91.         return $this->pictureFile;
  92.     }
  93.     public function getId(): ?int
  94.     {
  95.         return $this->id;
  96.     }
  97.     public function getFirstname(): ?string
  98.     {
  99.         return $this->firstname;
  100.     }
  101.     public function setFirstname(string $firstname): self
  102.     {
  103.         $this->firstname $firstname;
  104.         return $this;
  105.     }
  106.     public function getLastname(): ?string
  107.     {
  108.         return $this->lastname;
  109.     }
  110.     public function setLastname(string $lastname): self
  111.     {
  112.         $this->lastname $lastname;
  113.         return $this;
  114.     }
  115.     public function getSpeciality(): ?string
  116.     {
  117.         return $this->speciality;
  118.     }
  119.     public function setSpeciality(string $speciality): self
  120.     {
  121.         $this->speciality $speciality;
  122.         return $this;
  123.     }
  124.     public function getStorePage(): ?StorePage
  125.     {
  126.         return $this->storePage;
  127.     }
  128.     public function setStorePage(?StorePage $storePage): self
  129.     {
  130.         $this->storePage $storePage;
  131.         return $this;
  132.     }
  133. }