src/Entity/Pub.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PubRepository;
  4. use App\Validator as CustomAssert;
  5. use DateTime;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\HttpFoundation\File\File;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  12. /**
  13.  * @ORM\Entity(repositoryClass=PubRepository::class)
  14.  * @Vich\Uploadable
  15.  * @CustomAssert\PubClass
  16.  */
  17. class Pub
  18. {
  19.     /**
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue
  22.      * @ORM\Column(type="integer")
  23.      */
  24.     private $id;
  25.     /**
  26.      * @ORM\Column(type="datetime")
  27.      * @Assert\LessThan(propertyPath="end")
  28.      * @var DateTime|null
  29.      * @Assert\NotBlank
  30.      */
  31.     private $start;
  32.     /**
  33.      * @Assert\GreaterThan(propertyPath="start")
  34.      * @ORM\Column(type="datetime")
  35.      * @var DateTime|null
  36.      * @Assert\NotBlank
  37.      */
  38.     private $end;
  39.     /**
  40.      * @ORM\Column(type="string", length=255)
  41.      */
  42.     private $image;
  43.     /**
  44.      * @ORM\Column(type="text")
  45.      * @Assert\NotBlank
  46.      */
  47.     private $description;
  48.     /**
  49.      * @ORM\Column(type="datetime")
  50.      * @var DateTime|null
  51.      */
  52.     private $createdAt;
  53.     /**
  54.      * @ORM\Column(type="datetime", nullable=true)
  55.      * @var DateTime|null
  56.      */
  57.     private $updatedAt;
  58.     /**
  59.      * @Vich\UploadableField(mapping="pub_images", fileNameProperty="image")
  60.      * @Assert\File(
  61.      *     mimeTypes={"image/jpeg", "image/gif", "image/png"},
  62.      *     maxSize="700Ki",
  63.      * )
  64.      * @var File|null
  65.      */
  66.     private $imageFile;
  67.     /**
  68.      * @ORM\OneToMany(targetEntity=PubClient::class, mappedBy="pub", orphanRemoval=true,  cascade={"persist", "refresh", "remove"})
  69.      */
  70.     private $pubClients;
  71.     /**
  72.      * @ORM\Column(type="boolean", options={"default": "1"})
  73.      * @var bool
  74.      */
  75.     private $active true;
  76.     public function __construct()
  77.     {
  78.         $this->pubClients = new ArrayCollection();
  79.         $this->createdAt = new DateTime();
  80.     }
  81.     /**
  82.      * @return File|null
  83.      */
  84.     public function getImageFile(): ?File
  85.     {
  86.         return $this->imageFile;
  87.     }
  88.     /**
  89.      * @param File|null $imageFile
  90.      * @return Pub
  91.      */
  92.     public function setImageFile(?File $imageFile null): self
  93.     {
  94.         $this->imageFile $imageFile;
  95.         if ($imageFile) {
  96.             // if 'updatedAt' is not defined in your entity, use another property
  97.             $this->updatedAt = new DateTime('now');
  98.         }
  99.         return $this;
  100.     }
  101.     public function getId(): ?int
  102.     {
  103.         return $this->id;
  104.     }
  105.     public function getStart(): ?\DateTimeInterface
  106.     {
  107.         return $this->start;
  108.     }
  109.     public function setStart(\DateTimeInterface $start): self
  110.     {
  111.         $this->start $start;
  112.         return $this;
  113.     }
  114.     public function getEnd(): ?\DateTimeInterface
  115.     {
  116.         return $this->end;
  117.     }
  118.     public function setEnd(\DateTimeInterface $end): self
  119.     {
  120.         $this->end $end;
  121.         return $this;
  122.     }
  123.     public function getImage(): ?string
  124.     {
  125.         return $this->image;
  126.     }
  127.     public function setImage(?string $image): self
  128.     {
  129.         $this->image $image;
  130.         return $this;
  131.     }
  132.     public function getDescription(): ?string
  133.     {
  134.         return $this->description;
  135.     }
  136.     public function setDescription(string $description): self
  137.     {
  138.         $this->description $description;
  139.         return $this;
  140.     }
  141.     public function getCreatedAt(): ?DateTime
  142.     {
  143.         return $this->createdAt;
  144.     }
  145.     public function setCreatedAt(DateTime $createdAt): self
  146.     {
  147.         $this->createdAt $createdAt;
  148.         return $this;
  149.     }
  150.     public function getUpdatedAt(): ?DateTime
  151.     {
  152.         return $this->updatedAt;
  153.     }
  154.     public function setUpdatedAt(?DateTime $updatedAt): self
  155.     {
  156.         $this->updatedAt $updatedAt;
  157.         return $this;
  158.     }
  159.     /**
  160.      * @return Collection|PubClient[]
  161.      */
  162.     public function getPubClients(): Collection
  163.     {
  164.         return $this->pubClients;
  165.     }
  166.     public function addPubClient(PubClient $pubClient): self
  167.     {
  168.         if (!$this->pubClients->contains($pubClient)) {
  169.             $this->pubClients[] = $pubClient;
  170.             $pubClient->setPub($this);
  171.         }
  172.         return $this;
  173.     }
  174.     public function removePubClient(PubClient $pubClient): self
  175.     {
  176.         if ($this->pubClients->removeElement($pubClient)) {
  177.             // set the owning side to null (unless already changed)
  178.             if ($pubClient->getPub() === $this) {
  179.                 $pubClient->setPub(null);
  180.             }
  181.         }
  182.         return $this;
  183.     }
  184.     public function getActive(): ?bool
  185.     {
  186.         return $this->active;
  187.     }
  188.     public function setActive(bool $active): self
  189.     {
  190.         $this->active $active;
  191.         return $this;
  192.     }
  193.     public function __toString()
  194.     {
  195.         return (string)$this->id;
  196.     }
  197. }