<?php
namespace App\Entity;
use DateTime;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* Label
*
* @ORM\Table(name="label")
* @ORM\Entity(repositoryClass="App\Repository\LabelRepository")
* @ORM\HasLifecycleCallbacks()
* @Vich\Uploadable
*/
class Label
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @Groups({"api"})
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255)
* @Assert\NotBlank
* @Groups({"api"})
*/
private $name;
/**
* @var string|null
*
* @ORM\Column(name="picture", type="string", length=255, nullable=true)
*/
private $picture;
/**
* Not persisted
* @Vich\UploadableField(mapping="label_picture", fileNameProperty="picture")
*/
private $pictureFile;
/**
* @var DateTime
*
* @ORM\Column(name="createdAt", type="datetime", nullable=false)
*/
protected $createdAt;
/**
* @var DateTime
*
* @ORM\Column(name="updatedAt", type="datetime", nullable=true)
*/
protected $updatedAt;
/**
* @var string|null
*
* @ORM\Column(name="description", type="text", nullable=false)
* @Assert\NotBlank
*/
private $description;
public function __toString()
{
return $this->getName();
}
/**
* Get id.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set name.
*
* @param string $name
*
* @return Label
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set picture.
*
* @param string|null $picture
*
* @return Label
*/
public function setPicture($picture = null)
{
$this->picture = $picture;
return $this;
}
/**
* Get picture.
*
* @return string|null
*/
public function getPicture()
{
return $this->picture;
}
/**
* Set description.
*
* @param string|null $description
*
* @return Label
*/
public function setDescription($description = null)
{
$this->description = $description;
return $this;
}
/**
* Get description.
*
* @return string|null
*/
public function getDescription()
{
return $this->description;
}
/**
* @return DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Set createdAt
* @ORM\PrePersist
*/
public function setCreatedAt()
{
$this->createdAt = new DateTime();
$this->updatedAt = new DateTime();
return $this;
}
/**
* @return DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* Set updatedAt
* @ORM\PreUpdate
*/
public function setUpdatedAt()
{
$this->updatedAt = new DateTime();
return $this;
}
public function setPictureFile($pictureFile = null)
{
$this->pictureFile = $pictureFile;
if (null !== $pictureFile) {
$this->updatedAt = new DateTimeImmutable();
}
}
public function getPictureFile()
{
return $this->pictureFile;
}
}