<?php
namespace App\Entity;
use App\Repository\StoreEmployeeRepository;
use Doctrine\ORM\Mapping as ORM;
use DateTime;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass=StoreEmployeeRepository::class)
* @Vich\Uploadable
*/
class StoreEmployee
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $firstname;
/**
* @ORM\Column(type="string", length=255)
*/
private $lastname;
/**
* @ORM\Column(type="string", length=255)
*/
private $speciality;
/**
* @ORM\ManyToOne(targetEntity=StorePage::class, inversedBy="employees")
* @ORM\JoinColumn(nullable=false)
*/
private $storePage;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $picturePath;
/**
* @assert\File( mimeTypes = {"image/jpeg", "image/png", "image/gif", "image/jpg","image/webp"})
* @Vich\UploadableField(mapping="employee_images", fileNameProperty="picturePath")
* @var File
*/
private $pictureFile;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @return mixed
*/
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
/**
* @param mixed $updatedAt
*/
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getPicturePath()
{
return $this->picturePath;
}
public function setPicturePath(?string $picturePath)
{
$this->picturePath = $picturePath;
return $this;
}
/**
* @return bool
*/
public function hasPicture(){
return !is_null($this->picturePath);
}
public function setPictureFile(File $picturePath = null)
{
$this->pictureFile = $picturePath;
if ($picturePath){
$this->updatedAt = new \DateTime('now');
}
}
public function getPictureFile()
{
return $this->pictureFile;
}
public function getId(): ?int
{
return $this->id;
}
public function getFirstname(): ?string
{
return $this->firstname;
}
public function setFirstname(string $firstname): self
{
$this->firstname = $firstname;
return $this;
}
public function getLastname(): ?string
{
return $this->lastname;
}
public function setLastname(string $lastname): self
{
$this->lastname = $lastname;
return $this;
}
public function getSpeciality(): ?string
{
return $this->speciality;
}
public function setSpeciality(string $speciality): self
{
$this->speciality = $speciality;
return $this;
}
public function getStorePage(): ?StorePage
{
return $this->storePage;
}
public function setStorePage(?StorePage $storePage): self
{
$this->storePage = $storePage;
return $this;
}
}