src/Entity/Label.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use DateTime;
  4. use DateTimeImmutable;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use JMS\Serializer\Annotation\Groups;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  9. /**
  10.  * Label
  11.  *
  12.  * @ORM\Table(name="label")
  13.  * @ORM\Entity(repositoryClass="App\Repository\LabelRepository")
  14.  * @ORM\HasLifecycleCallbacks()
  15.  * @Vich\Uploadable
  16.  */
  17. class Label
  18. {
  19.     /**
  20.      * @var int
  21.      *
  22.      * @ORM\Column(name="id", type="integer")
  23.      * @ORM\Id
  24.      * @ORM\GeneratedValue(strategy="AUTO")
  25.      * @Groups({"api"})
  26.      */
  27.     private $id;
  28.     /**
  29.      * @var string
  30.      *
  31.      * @ORM\Column(name="name", type="string", length=255)
  32.      * @Assert\NotBlank
  33.      * @Groups({"api"})
  34.      */
  35.     private $name;
  36.     /**
  37.      * @var string|null
  38.      *
  39.      * @ORM\Column(name="picture", type="string", length=255, nullable=true)
  40.      */
  41.     private $picture;
  42.     /**
  43.      * Not persisted
  44.      * @Vich\UploadableField(mapping="label_picture", fileNameProperty="picture")
  45.      */
  46.     private $pictureFile;
  47.     /**
  48.      * @var DateTime
  49.      *
  50.      * @ORM\Column(name="createdAt", type="datetime", nullable=false)
  51.      */
  52.     protected $createdAt;
  53.     /**
  54.      * @var DateTime
  55.      *
  56.      * @ORM\Column(name="updatedAt", type="datetime", nullable=true)
  57.      */
  58.     protected $updatedAt;
  59.     /**
  60.      * @var string|null
  61.      *
  62.      * @ORM\Column(name="description", type="text", nullable=false)
  63.      * @Assert\NotBlank
  64.      */
  65.     private $description;
  66.     public function __toString()
  67.     {
  68.         return $this->getName();
  69.     }
  70.     /**
  71.      * Get id.
  72.      *
  73.      * @return int
  74.      */
  75.     public function getId()
  76.     {
  77.         return $this->id;
  78.     }
  79.     /**
  80.      * Set name.
  81.      *
  82.      * @param string $name
  83.      *
  84.      * @return Label
  85.      */
  86.     public function setName($name)
  87.     {
  88.         $this->name $name;
  89.         return $this;
  90.     }
  91.     /**
  92.      * Get name.
  93.      *
  94.      * @return string
  95.      */
  96.     public function getName()
  97.     {
  98.         return $this->name;
  99.     }
  100.     /**
  101.      * Set picture.
  102.      *
  103.      * @param string|null $picture
  104.      *
  105.      * @return Label
  106.      */
  107.     public function setPicture($picture null)
  108.     {
  109.         $this->picture $picture;
  110.         return $this;
  111.     }
  112.     /**
  113.      * Get picture.
  114.      *
  115.      * @return string|null
  116.      */
  117.     public function getPicture()
  118.     {
  119.         return $this->picture;
  120.     }
  121.     /**
  122.      * Set description.
  123.      *
  124.      * @param string|null $description
  125.      *
  126.      * @return Label
  127.      */
  128.     public function setDescription($description null)
  129.     {
  130.         $this->description $description;
  131.         return $this;
  132.     }
  133.     /**
  134.      * Get description.
  135.      *
  136.      * @return string|null
  137.      */
  138.     public function getDescription()
  139.     {
  140.         return $this->description;
  141.     }
  142.     /**
  143.      * @return DateTime
  144.      */
  145.     public function getCreatedAt()
  146.     {
  147.         return $this->createdAt;
  148.     }
  149.     /**
  150.      * Set createdAt
  151.      * @ORM\PrePersist
  152.      */
  153.     public function setCreatedAt()
  154.     {
  155.         $this->createdAt = new DateTime();
  156.         $this->updatedAt = new DateTime();
  157.         return $this;
  158.     }
  159.     /**
  160.      * @return DateTime
  161.      */
  162.     public function getUpdatedAt()
  163.     {
  164.         return $this->updatedAt;
  165.     }
  166.     /**
  167.      * Set updatedAt
  168.      * @ORM\PreUpdate
  169.      */
  170.     public function setUpdatedAt()
  171.     {
  172.         $this->updatedAt = new DateTime();
  173.         return $this;
  174.     }
  175.     public function setPictureFile($pictureFile null)
  176.     {
  177.         $this->pictureFile $pictureFile;
  178.         if (null !== $pictureFile) {
  179.             $this->updatedAt = new DateTimeImmutable();
  180.         }
  181.     }
  182.     public function getPictureFile()
  183.     {
  184.         return $this->pictureFile;
  185.     }
  186. }