<?php
namespace App\Entity;
use App\Repository\PubRepository;
use App\Validator as CustomAssert;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass=PubRepository::class)
* @Vich\Uploadable
* @CustomAssert\PubClass
*/
class Pub
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="datetime")
* @Assert\LessThan(propertyPath="end")
* @var DateTime|null
* @Assert\NotBlank
*/
private $start;
/**
* @Assert\GreaterThan(propertyPath="start")
* @ORM\Column(type="datetime")
* @var DateTime|null
* @Assert\NotBlank
*/
private $end;
/**
* @ORM\Column(type="string", length=255)
*/
private $image;
/**
* @ORM\Column(type="text")
* @Assert\NotBlank
*/
private $description;
/**
* @ORM\Column(type="datetime")
* @var DateTime|null
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
* @var DateTime|null
*/
private $updatedAt;
/**
* @Vich\UploadableField(mapping="pub_images", fileNameProperty="image")
* @Assert\File(
* mimeTypes={"image/jpeg", "image/gif", "image/png"},
* maxSize="700Ki",
* )
* @var File|null
*/
private $imageFile;
/**
* @ORM\OneToMany(targetEntity=PubClient::class, mappedBy="pub", orphanRemoval=true, cascade={"persist", "refresh", "remove"})
*/
private $pubClients;
/**
* @ORM\Column(type="boolean", options={"default": "1"})
* @var bool
*/
private $active = true;
public function __construct()
{
$this->pubClients = new ArrayCollection();
$this->createdAt = new DateTime();
}
/**
* @return File|null
*/
public function getImageFile(): ?File
{
return $this->imageFile;
}
/**
* @param File|null $imageFile
* @return Pub
*/
public function setImageFile(?File $imageFile = null): self
{
$this->imageFile = $imageFile;
if ($imageFile) {
// if 'updatedAt' is not defined in your entity, use another property
$this->updatedAt = new DateTime('now');
}
return $this;
}
public function getId(): ?int
{
return $this->id;
}
public function getStart(): ?\DateTimeInterface
{
return $this->start;
}
public function setStart(\DateTimeInterface $start): self
{
$this->start = $start;
return $this;
}
public function getEnd(): ?\DateTimeInterface
{
return $this->end;
}
public function setEnd(\DateTimeInterface $end): self
{
$this->end = $end;
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(string $description): self
{
$this->description = $description;
return $this;
}
public function getCreatedAt(): ?DateTime
{
return $this->createdAt;
}
public function setCreatedAt(DateTime $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?DateTime
{
return $this->updatedAt;
}
public function setUpdatedAt(?DateTime $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* @return Collection|PubClient[]
*/
public function getPubClients(): Collection
{
return $this->pubClients;
}
public function addPubClient(PubClient $pubClient): self
{
if (!$this->pubClients->contains($pubClient)) {
$this->pubClients[] = $pubClient;
$pubClient->setPub($this);
}
return $this;
}
public function removePubClient(PubClient $pubClient): self
{
if ($this->pubClients->removeElement($pubClient)) {
// set the owning side to null (unless already changed)
if ($pubClient->getPub() === $this) {
$pubClient->setPub(null);
}
}
return $this;
}
public function getActive(): ?bool
{
return $this->active;
}
public function setActive(bool $active): self
{
$this->active = $active;
return $this;
}
public function __toString()
{
return (string)$this->id;
}
}